I need to move my object horizontal and vertical on the global axes, while the object faces the mouse. if the object rotates, it’s axes rotate too, and the object will go toward the mouse. how can i fix this?
my move script:
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// move
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis("Vertical");
controller.SimpleMove(forward * curSpeed);
var right = transform.TransformDirection(Vector3.right);
var curSpeed2 = speed * Input.GetAxis("Horizontal");
controller.SimpleMove(right * curSpeed2);
}
I may be misunderstanding your question but it looks like you are specifically doing what you said you're trying to fix. If you don't use
– anon19958801transform.TransformDirection(Vector3.forward)and just useVector3.forwarddoes this fix our issue?That would do it. You should post that as an answer.
– equalsequals