Hi,
I have this script:
public float speed = 1.0f;
Vector3 movement;
Animator anim;
Rigidbody playerRigidbody;
void Awake ()
{
anim = GetComponent<Animator>();
playerRigidbody = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void FixedUpdate ()
{
float h = Input.GetAxisRaw ("Horizontal");
float v = Input.GetAxisRaw ("Vertical");
Move (h, v);
Animating (h, v);
}
void Move (float h, float v)
{
movement.Set(h, 0f, v);
movement = movement.normalized * speed * Time.deltaTime;
playerRigidbody.MovePosition(transform.position + movement);
}
void Animating (float h, float v)
{
bool walking = h != 0f || v != 0f;
anim.SetBool ("IsWalking", walking);
}
}
I have been struggling for some time to work with mecanim and playing animations while my player moves. This script works very well in that respect, however, I can’t seem to get the player to turn using the “a” and “d” keys. I have tried using the simple functions:
transform.Rotate(Vector3.up, turnspeed * Time.deltaTime);
However, even with that line this object will not turn, I do not know if the script I currently have is interfering with this function or if there is something else that needs to be done. Thank you for your time.