• News

• Industries

• Learning & Support

• Community

• Marketplace # Basic pawn movement questions!

Hi, new to UE4 but very much enjoying it so far.

I’m simply trying to get my head around creating a controllable flying pawn with 6 degrees of freedom using blueprints. I’ve gone through Epic’s Six-DOF Flying pawn tutorial: (https://wiki.unrealengine.com/Blueprint_Six-DOF_Flying_Pawn_Tutorial).

The tutorial works perfectly, but I have a few total beginner questions about the results. It works but I want to understand why. I have virtually no programming experience, nor do I have any experience with vectors so i’m a bit up against it learning curve wise. Any help with increasing my understanding of any of these points would be greatly appreciated.

First things first. Using the tutorial, I have arrived at the following (see image) to move the pawn forwards and backwards, and left and right based on the left stick input. So…

1.) Why am I using “Get Actor Rotation”. Should I not be getting the movement of the actor before adding further force in that direction or is that what the “Get forward Vector” does?

2.) I have no real understanding of Vectors but i’m guessing that the “Get Forward Vector” function is capturing the pawns movement through a set 2D plane, (hence get forward/right/up vector for different planes) Is this correct?

3.) The Input Axis value from the left stick is being fed in to a “Float*Float” I assume this is taking the input and multiplying it by the second, giving me a new greater or lesser value to feed to the next component in the blue print. But why are we multiplying and not adding say? And how does this cause acceleration? Is it performing this function every frame etc? If so, how does it know when to stop, why does the pawn seem to have a maximum speed?

4.) So now I have 2 values, a vector and a float, which are then multiplied together to produce our new velocity, which gets fed in to the “Set Physics Linear Velocity” Which accelerates our object in the correct direction. mathematically speaking, how is the float from the input from the stick being combined with the vector to determine the velocity and direction of the pawn?

I suspect I have hugely misunderstood much of the above, so again apologies for what are probably rather stupid questions.

Again any help, or direction toward tutorials or reading materials which cover these things would be much appreciated.

Thanks!

I don’t think I can explain vectors in just one post, there are so many things you can learn about vectors it’s like a huge chapter in mathematics.

First of all, the absolute most basic thing that you probably already know is that a 3d vector in UE4 is basically a variable that contains 3 float variables: x, y & z.

1. Get Actor Rotation returns the world pitch, yaw & roll values of an actor. The Get Forward Vector node calculates and returns the forward direction vector based on the rotation of the actor… for example if your actor has no rotation (pitch,yaw & roll = 0) then the forward direction vector will probably be 1,0,0 (meaning your actor faces directly in the X axis) and so on.
Now since you have the direction vector you can multiply it by whatever force float you want to make the actor move forward no matter what the actor rotation’s is, otherwise if you don’t use the direction vector then the actor might move sideways, diagonally etc. depending on the rotation (which is not a desirable thing in this situation).
I hope that kinda made sense… I’m not very good at this apparently lol… okay moving on.

2. Read answer #1 hopefully you understand what the Get Forward/Right & Up Vectors do.

3. The InputAxis MoveForward node returns a value between -1 and 1, (1= forward, -1= backwards) so in case you are using W & S keys it can only be 1, 0 (meaning no button is pressed) or -1.
So basically you have to multiply it with a number because adding will not give you the same result.
And yes this function is executing every frame as far as I know (even when no button is been held down).

4. Again, this should be pretty much answered in answer #1 but let me try and give you an example of what happens from start to finish.

Lets say your actor has a rotation of 0,45,0 (meaning it’s rotated by 45 degrees in the yaw axis), lets also say that you want the actor to be moving backwards with a force of 50 (so let’s also assume you are holding the S key down).

This is what is going to happen:
InputAxis MoveForward will return a value of -1, then we multiply it by 50, which gives us -50.
Secondly, we get the forward direction vector by plugin the Get Actor Rotation node to the Get Forward Vector node, which returns us a vector of ~ X=0.7, Y=0.7, Z=0.
Now we multiply the direction vector with our previous float of -50 which returns a vector that is equal to about -35, -35, 0… then we plug that into the velocity function which is going to add a backwards velocity of 50.

I’m sorry if this didn’t make much sense! my teaching skill is practically next to zero Nice post

That was a very kind post and it made perfect sense to me.

Fantastic stuff, that’s cleared up a hell of a lot. Thanks so much for taking the time to write that all out! Your teaching skills are much better than you think 