playMaker

Author Topic: Character Movement relative to Camera?  (Read 762 times)

dmcctab

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Character Movement relative to Camera?
« on: May 24, 2014, 01:37:23 AM »
Hi,

I am making a third person, rpg style game system. I have the character animated and he animates Idle/Run from unitys Animator system. He moves based on values from GetAxis then setting velocity.

The camera follows the position of an invisible object set up behind the character as parent. So now the character can move in all directions with the camera always facing behind him.

The problem is that when he is facing a direction on the X axis, pressing the forward key will move him on the Z as this was his original direction.

How could I go about solving this? Would I need to completely redo his movement function or is there an easier solution I am overlooking?

Thanks!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3201
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Character Movement relative to Camera?
« Reply #1 on: May 24, 2014, 07:05:18 AM »
The simplest way is to use Get Axis Vector. It has a parameter called Relative To. If you set this to the tracking camera then the movement vector will be relative to that camera.

If you want to do this manually look into the Transform Direction action. It transforms a direction vector from local space to world space; e.g., from the camera's space (input) to a world space vector needed to translate the character.