# playMaker

### Author Topic: Rotate rocket to face direction of travel?[SOLVED]  (Read 1112 times)

• Full Member
• Posts: 215
##### Rotate rocket to face direction of travel?[SOLVED]
« on: August 21, 2018, 03:45:12 PM »
I'm making a rocket that has a force applied to it to fly forward. Because it has a front and back end (unlike a sphere or something) I want it to update the rotation so the tip is always facing the direction of travel.

How do I do this?

My question isn't so much on rotating, I know about that, what I'm really asking is how I get the variable that matches the direction of travel to tell it to look at.
« Last Edit: August 24, 2018, 03:30:44 AM by jeanfabre »

#### jeanfabre

• Hero Member
• Posts: 15483
• Official Playmaker Support
##### Re: Rotate rocket to face direction of travel?
« Reply #1 on: August 22, 2018, 03:59:02 AM »
Hi,

get the velocity of your object, it contains the direction of the travel. you can use GetSpeed if it's a RigidBody, or you can use GetGameObjectSpeed from the Ecosystem, if it's a non rigidbody object.

use that as the vector to point your rocket to its own trajectory.

Bye,

Jean

• Full Member
• Posts: 215
##### Re: Rotate rocket to face direction of travel?
« Reply #2 on: August 22, 2018, 09:57:20 AM »
Hi,

get the velocity of your object, it contains the direction of the travel. you can use GetSpeed if it's a RigidBody, or you can use GetGameObjectSpeed from the Ecosystem, if it's a non rigidbody object.

use that as the vector to point your rocket to its own trajectory.

Bye,

Jean
I've had a look but the Get Speed action produces a Float variable. I'm not sure how I'm meant to use that as a vector 3 since it's a single number?

EDIT: Oh I think you meant Get Velocity. I'm trying that now
« Last Edit: August 22, 2018, 10:04:28 AM by daniellogin »

• Full Member
• Posts: 215
##### Re: Rotate rocket to face direction of travel?
« Reply #3 on: August 22, 2018, 10:58:00 AM »
Oh my god, I think I tried EVERY FRICKEN COMBINATION YOU CAN IMAGINE for the Get Velocity and Smooth Look At.... but I finally got it right. I also had to rotate my game object/child objects (well at least I think I had to...).

So for anyway, thanks to @jeanfabre for the help.

For anyone else who wants to know the full details, it goes like this:

* Get Velocity
> of rocket
> gives you vector variable

* Smooth Look At
> rocket is gameobject
> Up Vector set to the vector variable
> Keep Vertical enabled
> Finish Tolerance set to none

WRONG

See another post below for correct answer. I don't know how I thought it does, but the above DOES NOT work.
« Last Edit: August 24, 2018, 09:29:26 AM by daniellogin »

#### jeanfabre

• Hero Member
• Posts: 15483
• Official Playmaker Support
##### Re: Rotate rocket to face direction of travel?
« Reply #4 on: August 24, 2018, 03:30:35 AM »
Hi,

Thanks for the details indeed you need to fiddle with all these options to get things right. I am glad you got it in the end, never giving up is the key!

Bye,

Jean

• Full Member
• Posts: 215
##### Re: Rotate rocket to face direction of travel?[SOLVED]
« Reply #5 on: August 24, 2018, 09:35:17 AM »
ARH

Just so I can pull all of my hair out, I just did another hour + of trying every single combination of more actions!

My original answer was wrong. Didn't work. I don't know how I thought it worked but it doesn't.

This time it does.....

*Get Velocity
> rocket gameobject
> save the vector as variable
> space Self (it almost worked but spun out of control on World like an unstable rocket)
> every frame of course

* Rotate
> rocket gameobject
> vector is the one saved by get velocity
> leave X Y and Z and 'None'
> Space is Self
> Every Frame

This works. It took way too long for me to figure this out but dammit it works.