Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: JonathanBurroughs on March 24, 2014, 02:16:37 PM

Title: [SOLVED] Detecting change in mouselook camera rotation to drive character anims
Post by: JonathanBurroughs on March 24, 2014, 02:16:37 PM
Hello all,

I've adapted the basic third person character controller setup to work as a first person player:

"Get Axis Vector" and "Controller Simple Move" on the parent player object, "Mouse Look" on the Main Camera child object.

What I also want is to have an animated player body.

I've placed a character mesh as the child of the player parent object and added a Mechanim Animator Controller and animation to it. I'm passing the "Get Axis Vector" Magnitude float to the Anim Controller to switch between Idle and Moving animations.

What I'd like to do is have the player model turn and animate according to left and right turns as driven by the camera. I'm updating the rotation of the player mesh to match the camera rotation, so I get a shopping trolley turn effect right now.

If I want to check changes in rotation to the Main Camera what is the best way to achieve this?

Any assistance greatly appreciated!
Title: Re: Getting change in camera rotation to drive animation
Post by: JonathanBurroughs on March 25, 2014, 08:47:03 AM
A little bump! Just in case this has gone unseen.
Title: Re: Detecting change in mouselook camera rotation to drive character animation
Post by: JonathanBurroughs on March 25, 2014, 11:35:36 AM
Okay, I'm going to experiment with detecting an initial camera rotation and then checking for a defined change from that rotation, at which point an animation is triggered.

I figure some mix of Get Rotation, Float Compare and a few other math functions is going to be what I need.

Wish me luck!
Title: Re: Detecting change in mouselook camera rotation to drive character animation
Post by: JonathanBurroughs on March 25, 2014, 01:01:21 PM
Running into trouble comparing rotations which pass through 360 / zero degrees. Hmm!
Title: Re: Detecting change in mouselook camera rotation to drive character animation
Post by: JonathanBurroughs on March 26, 2014, 08:47:23 AM
Solved!

http://hutonggames.com/playmakerforum/index.php?topic=47.0

Took a look at the post above. Now using Get Axis to identify the Mouse X inputs and am feeding them into a Mechanim Animation Controller as an Animator Float. This lets me trigger turn animations if the right conditions are met. Awesome!