Add Impulse and get forward vector help

Hey guys,

I am having a confusing dilema trying to create a thrust in the direction of my ship blueprint. I am hoping i am just interpreting something wrong.

I have created the thrust mechanism exactly how i want it, the problem is the direction of the thrust.

I use GetActorForwardVector, which i presumed was the current direction my ship was facing. But this doesn’t appear to be the case, it just uses the world Y axis instead of the local Y axis translated to world vector.

So simple question I just cant find anything that explains it in plain terms to give me a solution as everyone’s situation is different.

How do i get the world vector that the Y axis of my ship is facing.

I know this is probably simple and I’m missing some basic knowledge here, but I just gone brain dead!

Thanks in advance

Stewart

Hey @High500!

If you are looking for the world rotation of your ship, have you tried instead using “Get World Rotation”?

I hope the above is the solution you need!

The component’s, actor’s and world’s forward vectors can differ:

  • in Unreal X red is forward
  • an actor can have its own fwd as it’s rotated in the world
  • each scene component can also have a unique forward that is relative to the owning actor:

image

green Y is Right, blue Z is the Up vector, and the same rules apply as above.


It often comes to down to the hierarchy:

image

If I rotate only the static mesh component but use the entire Actor’s forward, I’d go in the wrong direction.

The first thing I’d do is to place the simulating colliding component at the root of the actor. This way you can use actor forward and it will always make sense. Not to mention that offsetting simulating components in asking for trouble.


A recent example of using forward vector to thrust in the desired direction:

Thanks @Quetzalcodename , i did consider it but i would then have to do a calculation to create a vector based on those rotation values, i was hoping there was a simple translation to get the vector rather than do a whole function to calculate it based on rotation.

if i have to i sill, but optimisation i was thinking ahead!

stewart

image

World forward would be just 1,0,0

Thanks for this, this may have been suitable , but i guess i neglected to say im using gravity, whence the add impulse which works great as a manouvering thruster against the gravity without complex coding.

I apply the thrust to the forward vector of the actor which is facing up, it falls and thrusts properly but does not then take into account when i rotate or physics rotates the ship

It’s precisely as I mentioned above. You’re adding physics to Hull but use the forward of Actor.

If you want to simulate physics reliable, ensure the simulating / colliding component is at the root of the actor. Or is Hull already the root? Can we see the hierarchy of the actor?

add impulse requests a component? is there an add impulse that applies actor wide? thanks btw this is helpful

Yes, but if you’re adding an impulse to a component that is not the root, here is what happens:

The actor sits still at the bottom, it’s forward is not changing while the Hull flies away… I believe you want the whole thing to move, right?

Yeah the whole ship is to fly, the hull is the root of the ship, but when i change the hull to be the root, i get a sideways motion not in the direction of the ship, and it appears i cannot rotate the hull object in the BP viewport. is that normal?

This is a bit confusing and contradicting. Could you show the hierarchy?

and it appears i cannot rotate the hull object in the BP viewport. is that normal?

I feel that your mesh is not facing the right way to start with - this is something that you need to take into account before you import it.


If this was rocket ship that is supposed to launch upwards, you’d need to ensure that the mesh that was created and already oriented correctly in the software it came from:

yes i agree, but as it is just a test blueprint im using static mesh simple primitives for a ship until im happy with the movement.

Sorry the Hull is the root of the components of the ship but NOT the scene root of the BP, like this the hull always thrusts along upwards regardless of rotation.
I made the change you suggested and overide the scene root with the hull now the cone (hull) is facing the Red X but the code i use doesnt thrust un the direction of the hull, it thrusts into the Y axis.

and i cannot rotate the static mesh for the hull any longer, should i restore the scene root, and thrust against that? or did i miss the point. sorry trying to make it clear as ppossible.

For now, just to get you going you can use forward of the component providing it’s oriented correctly:

But the actor itself will not move, and since you need to rotate the mesh to visually match your expectations, it will be confusing an axis will not match with those of the engine.

In the future, when you’re working with meshes, ensure that their forward is where it’s supposed to be.


Taking your cone as an example:

image

Look where its forward is… the red arrow. If this is rocket you’d want to use UP vector. Using forward of this thing would push it slightly to the left.

so would UP work if i rotated the actor? would it still move the direction of the actor?

surely theres a way to use physics as a complete actor rather than individual components, would make this much simpler for me anyway :rofl:

surely theres a way to use physics as a complete actor rather than individual components, would make this much simpler for me anyway

Ofc:

This cone is pointing up, that’s how it was created, if you want it to move where it’s pointing, use up vector:

ok maybe the moving and replacing of the scene root kept the rotated values of the cone. i will replace it wit ha new cone and see what happens and report back.

really do appreciate the input! and the speedy responses!

bingo, thanks, seems i got it to work , the cone was indeed keeping the modified rotation when i copied it over the scene root. resetting it with a new cone did the trick and used to up vector as suggested. thank you very much.

Much appreciated!

Have a bit more testing and im sure bugs galore will appear but im on the right track the thrust is working now.

1 Like

Wicked! Since you’re exploring this, note there are also these bad boys:

Since you absolutely can have multiples, and each facing in any direction you want, things get spicy!

Good luck and have fun.

1 Like

This is actually a bug that has been there since… forever. Were you to restart the editor, it would go away. Off / On often does it.

:rofl: :rofl: :rofl:

After all that theres a component already, i was quite chuffed about my little routine for the thrust. At least i learned something. I may make a 2nd ship to test with and add those little puppies to compare!.

testing the rotation controls next to see how well my own code fares.

really thanks again. google is great but if you dont word things exactly right , or others situations are different enough to confuse you , this place and you guys is invaluable!

1 Like