- Home /
Using Vectors and Rotation for Movement,Using vectors to make gameObject move
I am trying to use vectors and rotation to make a gameObject move. Currently the movement is fine but the rotation is not matching the vector direction.
private void UpdateMotion() { transform.Translate(direction * mHeroSpeed * Time.deltaTime); transform.rotation = Quaternion.Euler(0, 0, playerAngle * (180/Mathf.PI)); }
private void ChangeDirection()
{
if (Input.GetKey(KeyCode.A)){
playerAngle = playerAngle + .01f * kHeroRotateSpeed;
float x = Mathf.Cos(playerAngle);
float y = Mathf.Sin(playerAngle);
Debug.Log(playerAngle);
Debug.Log("x: " + x);
Debug.Log("y: " + y);
direction.Set(x, y);
}
}
Comment