playMaker

Author Topic: [SOLVED] Detecting change in mouselook camera rotation to drive character anims  (Read 1418 times)

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
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!
« Last Edit: March 26, 2014, 05:48:44 AM by HiFiHair »

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
Re: Getting change in camera rotation to drive animation
« Reply #1 on: March 25, 2014, 05:47:03 AM »
A little bump! Just in case this has gone unseen.

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
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!

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
Running into trouble comparing rotations which pass through 360 / zero degrees. Hmm!

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • View Profile
    • @HiFiHair
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!