I have implemented a click 2 move script and i'm trying to use a method that already gets a Vector3 of where I clicked and moves the player via CharacterController to it.
is there a way to take the transforms current position, get the values from GetAxis while the keys are down and calculate its new position. when the vertical/horizontal controls are release the Vector3 would be assigned the transforms current position so it will stop moving
the is what is used to move to the position.
void MoveToPosition()
{
if (Vector3.Distance(transform.position, position) > 1)
{
Quaternion newRotation = Quaternion.LookRotation(position - transform.position);
newRotation.x = 0f;
newRotation.z = 0f;
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * 10);
controller.SimpleMove(transform.forward * speed);
animation.CrossFade(run.name);
}
else
{
animation.CrossFade(idle.name);
}
}
position is assigned from a raycast so I would like to use the players current position, what ever the calculations are required with getaxis and adjust accordingly