- Home /
Question by
tsig · Oct 10, 2013 at 12:55 AM ·
movementaxisgizmotranslation
Axis/Gizmo Translation Movement
Hello,
I need help with the axis movement for a gizmo tool. I want the movement like Unity's gizmo, based on camera view and object's rotation. I am current creating a plane to get mouse input and trying to project the input on the axis, but not working out.
float hitDistance = 0.0f;
Ray ray= Camera.main.ScreenPointToRay(Input.mousePosition);
plane = new Plane(Camera.main.transform.forward,object.position);
if (plane.Raycast (ray, out hitDistance))
{
_currIntersectPosition = GetIntersectPoint (hitDistance, ray);
Vector3 inputDelta= _currIntersectPosition - _lastIntersectPosition;
_lastIntersectPosition= _currIntersectPosition
//if on x-axis
objMovement = Vector3.Project (inputDelta, object.right);
object.position+= objMovement;
}
How do I convert mouse input to local axis movement? Any help appreciated
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613115641im_/https://answers.unity.com/themes/thub/images/avi.jpg)