- Home /
Question by
VAN-D00M · Mar 09, 2016 at 02:53 PM ·
scripting problemmovementmovement scriptanimator controller
Getting Unusual Input into Animator Controller Script
Hi,
We are tyring to get an animator controller working with our movement script. As the cameras change and the character moves relative to the cameras position, the input method is something we are struggling to convert to pass into the animator controller.
This is our movement script.
if (Input.GetKey (KeyCode.RightArrow)) {
movement = transform.position += Camera.main.transform.right * speed;
hammy.transform.rotation = Quaternion.LookRotation (Camera.main.transform.right);
anim.SetFloat("Speed", speed);
}
else if (Input.GetKey (KeyCode.LeftArrow)) {
movement = transform.position -= Camera.main.transform.right * speed;
hammy.transform.rotation = Quaternion.LookRotation (-(Camera.main.transform.right));
anim.SetFloat("Speed", speed);
}
if (Input.GetKey (KeyCode.UpArrow)) {
movement = transform.position += Camera.main.transform.forward * speed;
hammy.transform.rotation = Quaternion.LookRotation (Camera.main.transform.forward);
}
else if (Input.GetKey (KeyCode.DownArrow)) {
movement = transform.position -= Camera.main.transform.forward * speed;
hammy.transform.rotation = Quaternion.LookRotation (-(Camera.main.transform.forward));
}
We are at wits end and have tried many things but we just cant get our heads round it. Our paramater in the animator is Speed.
Any help would be greatly appreciated.
Comment
Hey, could you describe the unusual results you're getting?