Download

Move player in certain direction after being rotated.

I’m currently making a side scrolling space game and I made the player move along the z axis and have the ability to rotate in the pitch. I’m trying now to make the player move in a certain direction after being rotated. Since there is zero gravity, I need to have the player rotate and then use like a thrust to move in that direction. (Kind of like the game Lunar Lander) where the player rotates and then thrusts to move and slow itself down.

I’ve tried many different blueprints that I’ve looked up, but haven’t had any luck. I’ve also tried making my own, but still no luck. Can anyone tell me how i would get this started or does anyone have similar blueprints?

Any help is greatly appreciated!:slight_smile:

Thanks Mike

You can use simulate physic on your mesh and then use the nodes related to physics, like add force, set PhysicLinearVelocity…, there is a lot you can do with it, it works very well for my game.

Yup as Raikoh wrote, just few additional pointers:
make sure that your actor has collision and physics material (that is if you ever want your player to bounce or collide).
second: use constrains to limit physics to only one surface (just lock one axis)
remember to turn on autoactivate for thrusters.

Thank you for all your help! I’m still having a little problem though. When I press my thrust button, it just pushes my player over. (I’m trying to attach the thruster to the bottom of my block to make like a rocket ship). Do I have to attach a physics thruster to my component or do I need to make a socket and attach it there? Also when I turn the physics on my axis input quits working (When I press F & S, my player wont move left to right) This is what I have so far:

P.S: Sorry for the large images:)

I also tried moving the physics thruster on the mesh, but it still just pushed it over. It didn’t matter where I put it, it has the same effect.

I was able to achieve the movement you are describing by using the AddMovement function to a character class actor then using GetForwardVector for the world direction and the thrust axis value for scale. However this does not work with physics (as far as I can figure)… I am also trying to figure that part out.

I made a post in Content Creation. https://forums.unrealengine.com/showthread.php?53847-Customizing-movement-and-physics

if you follow the instructions there I think you will find the movement you are looking for.

Its not the ideal fix but it get us moving in the right direction. When I apply physics to my example in that post it seems like I get some constant unwanted movement input… usually roll to the left. Screws everything up. I cannot identify the source. Let me know how this works for, I would love to know.

Moose

I don’t think you can use physics thruster like that, i don’t really remember but i tried using them 3-4 months ago and i found that they are not to be used for that.
You can use physics directly on your mesh and use add force node to do like the thruster would do, but it’s a lot easier to control.

So if i understand correctly what you want to do:

  • create pawn blueprint
    -add a mesh (the ship)
    -simulate physics on it, turn of gravity
    -use the add force node (for the vector input : get actor rotation -> get forward vector -> multiply the vector by your speed).

it should look like space movements.

edit : turn off linear and angular damping too.

Turning UP the angular dampening solved my “rotate crazily out of control” problem I have it set to 2 now. I subtracted the ForwardVector from the WorldLocation to get a point 1 unit behind the ship but I think you can also “suck” with an Impulse if you give it negative strength.

Anyway, thanks Raikoh for mentioning the dampening thing. :slight_smile: I couldn’t test anything useful while my guy was spinning away.

I’ve tried all the options you guys have provided but still no luck. With one of the options(I can’t remember which) it just moved my guy to the right. Ralkoh or maniacalMoose, can you post a screenshot of your setup so I can see how you got it to work?

It’s very simple, the pin above AccForward is the axis value of input event.
2c58b3b61c38fccab5181086d2d4465b8072e77b.png

8ee49e1b5c33b0936252f972fa1579cdb7110017.jpeg

Michael, you said that you got the object to move but only to the right??? be aware that the way an fbx gets imported (and for that matter originally created and exported) is going to have an effect on its transform in the UE world. If you notice, I add back an “offset” for the location of my impulse, thats because subtracting the forward vector from the world location (which should give me a point directly behind the object) caused slightly down and right forward movement. So directly behind the location is not really directly behind the mesh because it was scaled when it was imported. I hope that makes sense and I hope this helps.

Moose

Moose, Michael wishes to do this by pushing a button, not rotating a joystick. Would Axis Events help us with this? Currently, we have the rotating movement, but cannot get the actor to thrust in any direction other than straight up, regardless of which direction the actor is facing. If you can help, please refer to our other Thread: Speeding up Player Over Time. Thank you for your help thus far.

Raikoh, what is connected to the multiply node at “AccForward?” And what is the “MainBody” Variable? Could we just use “Self?”

Well the node are not the same since the new version1.png
If you use the top node u don’t need a target, you select the target before placing the node.

Mainbody is the root and it’s a mesh component.

I got it to work! Thanks everyone for your help. I will get it directly to Michael from here.