- Home /
Child attached to Player Parent spins Uncontrollably when Script is Attached
I've spent weeks trying to animate the objects on my player parent. My current challenge is when I rotate my parent object with torque, the children objects that I've attached scripts to, spin out of control even though the script conditions have not been met. Ironically, when I hold the objects still or move them forwards or backwards, they behave perfectly. No Rigidbody, Collider or other components are attached to the child object except Transform, Mesh, Mesh Renderer and Shader. Here is the script:
public class AttackBite : MonoBehaviour {
public float mandibleStartAngle = 80;
public float mandibleStopAngle = 120;
public float mandibleRotationZ = 0;
public float animationSpeed = 15;
void FixedUpdate () {
//Bite
if (Input.GetMouseButton (1)) {
//Close Mandibles
transform.localRotation = Quaternion.Slerp (transform.rotation, Quaternion.Euler (0, mandibleStopAngle, mandibleRotationZ), Time.deltaTime * animationSpeed);
}
else {
//Open Mandibles
transform.localRotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, mandibleStartAngle, mandibleRotationZ), Time.deltaTime * animationSpeed);
}
}
}
Any help you can provide would be greatly appreciated. Thanks
Your answer
Follow this Question
Related Questions
How do I access/use the variable inside a script when the script name is unknown but objectname is? 3 Answers
Make a simple tree 1 Answer
Change render of all children 1 Answer
How to Left Trigger and West button at the same time - new input system 0 Answers
Enabling child particle system seperately from parent 2 Answers