playMaker

Author Topic: 'Look At' direction of movement. [SOLVED]  (Read 4787 times)

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
'Look At' direction of movement. [SOLVED]
« on: May 07, 2014, 05:46:12 AM »
Hey fellow playmakers,

So I'm onto my next problem

I need to work out the direction that an object is moving in so that I can use that to do a Look At action and use that variable.

My question is, how do I work out what direction the player is moving in? In my head the way is to take a Vector3 and then another after a set time later. Compare the two and then find out the exact opposite of that, and thats the direction you are moving in.

Im wondering if there is a cleaner way of doing this and if anyone can give me some tips on how to do it?

Thanks in advance
Terry
« Last Edit: May 07, 2014, 05:49:22 PM by tezer86 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 'Look At' direction of movement.
« Reply #1 on: May 07, 2014, 08:47:33 AM »
Hi,

 that would be one way.

 You can get the speed of your player, and the direction of the speed would indeed be the direction of your player.

use "Get speed" action.

 if your player is not a rigidBody, I made a custom action to get the speed of noon rigid body.

http://hutonggames.com/playmakerforum/index.php?topic=1182.msg4961#msg4961

Bye,

 Jean

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: 'Look At' direction of movement.
« Reply #2 on: May 07, 2014, 11:34:54 AM »
Hey Jean,

Thanks for the quick reply, I will try thus when I get back tonight.

Cheers
Terry

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: 'Look At' direction of movement.
« Reply #3 on: May 07, 2014, 02:31:05 PM »
Just looking at it now, How do I work out the direction of speed?

cheers
Terry

tezer86

  • Playmaker Newbie
  • *
  • Posts: 23
Re: 'Look At' direction of movement. [SOLVED]
« Reply #4 on: May 07, 2014, 02:46:21 PM »
Ah ok I have it, I got velocity and then used that to 'Look at Direction’. Thanks a lot for your health.

Martin-Vaupell

  • Junior Playmaker
  • **
  • Posts: 70
  • Creating CarbonDiOxide
    • Evisystems
Re: 'Look At' direction of movement. [SOLVED]
« Reply #5 on: May 08, 2014, 12:45:31 PM »
Ah ok I have it, I got velocity and then used that to 'Look at Direction’. Thanks a lot for your health.

Mind sharing a screenshot of the working solution, just the action states.
really curious about this.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: 'Look At' direction of movement. [SOLVED]
« Reply #6 on: May 08, 2014, 05:50:14 PM »
Ugh, I feel stupid for getting the old position, getting the current position, subtracting them to get the change per frame, and using that as a direction...

Then I moved to simply looking at the old position.  (which always faced backwards)

I've been doing that on so many projects...  :-[

I could have just used the current velocity! DOH!  :o

EDIT: Here's some screenshots of 'looking at velocity'.

« Last Edit: May 08, 2014, 06:09:42 PM by TrentSterling »