04-21-2014 02:44 PM
InteractionBox iBox = frame.InteractionBox;
HandList hands = frame.Hands;
Hand firstHand = hands [0];
Vector stabilizedPosition = firstHand.StabilizedPalmPosition;
Vector handCenter = stabilizedPosition;
Vector normalizedPosition = iBox.NormalizePoint(handCenter);
float x = normalizedPosition.x * screenWidth;
float y = normalizedPosition.y * screenHeight;
Camera.main.ScreenPointToRay(new Vector2(x,y));
if (Physics.Raycast (ray, out hit, Range))
{
//hit stuff
}
04-21-2014 03:03 PM
04-24-2014 05:05 PM
04-25-2014 09:34 AM
direction = cameraTransform.TransformDirection (Vector3.forward);
Vector2 cursorPos = new Vector2(x,y);
NextFire = Time.time + FireRate;
if (Physics.Raycast (cursorPos, direction, out hit, Range))
04-25-2014 10:34 AM
04-25-2014 08:22 PM
Vector normalizedPosition = iBox.NormalizePoint(handCenter);
float x = normalizedPosition.x;
float y = normalizedPosition.y;
float z = normalizedPosition.z;
Vector3 cameraPos = transform.position;
Vector3 cameraDir = transform.forward;
Vector3 cursorPos = new Vector3(x,y,z);
Vector3 direction = cameraDir + cursorPos;
//denormalize
float directionx = direction.x * screenWidth;
float directiony = direction.y * screenHeight;
float directionz = direction.z * screenWidth;
Vector3 rayDirection = new Vector3(directionx,directiony,directionz);
if (Physics.Raycast (cameraPos, rayDirection, out hit, Range)){
}
04-26-2014 08:29 AM
as well as being off-center to the sides.
04-26-2014 10:55 AM
"vajra3d" wrote:
Have you taken the right camera's off-centered position into account?
04-30-2014 08:45 PM
if (x>0.5)
ray = Camera.main.ScreenPointToRay(new Vector2(640 + x - (320 - Mathf.Abs (x) )/5, y ));
else if (x<0.5)
ray = Camera.main.ScreenPointToRay(new Vector2(640 - x - (320 - Mathf.Abs (x) )/5, y ));
else
ray = Camera.main.ScreenPointToRay(new Vector3(x,y,z));