- Home /
Rotating arm with Animation Event
I want to do the arm following the mouse, but a bit different. So I figured out that what I needed is an Animation Event. So I programmed the code and inserted the event and it doesn't work! It's a puppet character.
Transform Tree:
-Player
-Body
-Head
-Face
-Left Arm Upper
-Left Arm Lower
-Left Weapon
-Right Arm Upper
-Right Arm Lower
-Right Weapon
-Left Leg Upper
-Left Leg Lower
-Right Leg Upper
-Right Leg Lower
Animator is on the Player. I made a code into the PlatformCharacter2D, so it can show into the animator:
void AimLeftArm () {
Vector3 difference = Camera.main.ScreenToWorldPoint (Input.mousePosition) - LeftUpperArm.position;
difference.Normalize ();
if (LeftUpperArm.transform.root.localScale.x == 1) {
float RotZ = Mathf.Atan2 (difference.x, -difference.y) * Mathf.Rad2Deg;
LeftUpperArm.rotation = Quaternion.Euler (0f, 0f, RotZ);
}
else if (LeftUpperArm.root.localScale.x == -1) {
float RotZ = Mathf.Atan2 (difference.x, -difference.y) * Mathf.Rad2Deg;
LeftUpperArm.rotation = Quaternion.Euler (0f, 0f, -RotZ);
}
}
But it doesn't move the arm!
Comment
Your answer
Follow this Question
Related Questions
Animating a model 2 Answers
Character face camera direction when this pass a rotation limit 0 Answers
Abrupt change of position between animation transition 2 Answers
Animate character sitting in a chair 1 Answer
character animation 0 Answers