I am trying to build a movement system on my own, but it does not work so far. Even just turn left or right seems to be beyond my understanding. The tutorials usually seem to either go the physics route, which I do not want to go, or refer to an old unreal engine version, that doesn’t use advanced input mapping contexts.
I have a simple space ship pawn, that uses a simple cone mesh and a camera and a floating movement component. But the implementation of the axis1D inputs and the implementation in the blueprint of the pawn fails me direly. I know it’s easy and just needs half a dozen of nodes. But I just don’t know how to do it. Does anyone have an idea?
Can you show a screenshot from the game view?
Cause it varies what kind of a movement you want to nail down.
Topdown
Isometric
Follow camera with 3D movement elements.
etc can effect it, so we can give a more decent answer to your question.
Cause I can think of a lot different arcade ship movement
I am using the third person template. The game starts with the player as a person and it can use different vehicles. It’s just a learning project.
The view I get when I enter this cone, which is the space ship pawn, is basically the “cockpit” view, but it will be toggleable between third person camera hovering over and behind the space ship, flyby camera, cockpit camera and turret camera.
Basically, I am looking for roll, pitch, yaw, acellerate and decellerate functionality. It can already shoot.
I use different input mapping contexts for the player character and the space ship.
Allright, no worries.
It really depends on the game feel and it’s taste always comes from the cook, which is you. So you will find it gradually playing with it.
Couple of things.
- Using physics simulation is not the best way already, since its harder to control.
- When we do movement its generally kinematics simulation, meaning physics engine itself is a simulation of different physics variables, like gravity. In end its physics.
- Using the current unreal’s movement component would solve a lot of problems, it can be extended always. Sometimes like in a spaceship movement can be super complex and have to adapt environments. When you are in deep space vs when you are close to rigid body, when you are close to a rigid body with atmosphere , what about aerodynamics
etc.
For learning, its a good start.
I will just put a demo controller modification below from blueprints and the rest is basically experimenting with it.
I just changed character movement component to flying that is already existing and modified this value
added couple of blueprint nodes to simulate a space environment.
No gravity, leans on strafe a bit, and on forward movement adds a bit impulse to accelerate , decelarate.
On up and down applies a little bit force of stafe.
Result is a linear arcade movement like below.
This is just to concept things out. There is many details to it and movement is a core aspect of a game, it is not easy as it sounds and it gets complicated in no time. However there is a very extensive codebase already created with it for you to use. Rest is expanding it.
If you need something really custom like a space ship, moving close to ground and you want to do tricks with the controls, react to terrain etc. you need to code since blueprints will be very painfull after a certain stage.
EDIT :
I input mouse look to pawns rotation and input move X vectors to pitch to give my pawn additional roll ability as seen below. So right now as a simple move, can pitch, yaw, accalerate forward, backward, strafe up and down.
Result
Roll can be on mouse, of shift A-D to roll depends on how you feel about them and overall experience.
Please do not hesitate to ask. Hope it helps you to keep going.
Wow. I didn’t expect you to code a very example. Thank you so much for your effort. This definitely helps me tinkering along towards wisdom.
no worries enjoyed it, made an edit with some look directions, pitch yaw additions etc.
Happy developing.
All right. I tinkered with it. Is there any way to do a non-physics approach using the floating pawn movement component, in needed? I prefer not to use physics. Or can anybody tell me the pros and cons of using physics and non-physics movement?
I also realized I need to add angular acceleration until a certain angular speed is met or else it doesn’t feel right.
A non-physics approach I found, is the following:
This is what I want for turn pitch roll as well.
I have this a strafe. It does work and has a smooth acceleration to it (I don’t know why though. Probably, it uses the acceleration defined in the floating pawn movement component):
What it fails to do, is the abrupt strafing stop, when I stop pressing the input to strafe. The acceleration is active, but not the decceleration.
The problem is, that the provided solution from RedGrimnir is great and works and there is absolutely nothing to complain about. But his method does use physics or else the impulse can not be applied. But I’d rather have a non-physics solution.
Well as mentioned, there is no downside to making movement without a physics simulation.
What happens in the background is again just physics anyway It is something we call Kinematics. Which is describing motion without the use of forces which you don’t have to worry about it.
It is correct way of approach for arcade ship movement. You are using CharacterMovementComponent when you are making an Add Movement Input.
You don’t have to worry about physics (since you are asking without physics), I am a Physics Engineer, Physics is the father of all sciences. Every motion in the engine you see is physics either that way or this way. Even if we are talking on this forum with ease with you, its because a smart physicist invented transistor In short, this argument without phsyics is not a valid question. So let’s get over it cause Movement itself is the subject of physics.
Just wanted to say, don’t want to make a shortcut answer to your concerns. Let’s come to strafing stop issue you are having. Since you are using floating pawn movement (and if there is not other movement component interfering)
You should normally stop but maybe deceleration factor is low so you can increase it.
So, there is no performance disadvantage by using the physics approach? Because if no, I just finally use your method and have the subject movement completed
A very important thing: Using physics disables collisions. That seems wrong to me.
Fundamentally there will be more, cause when you enable physics simulation, as described Simulation every physics aspect of the game (which you will eventually use) is subject to effect your ship.
Ex:
Phsyics Sim : You hit a meteor, inertia of the impact is transferred both ship and meteor effecting their directions in space.
Without Sim : You hit a meteor, depending on collision setup
- Maybe pass through it resulting no impact calculation.
- Maybe It will collide: but it is going to ignore radial impulse cause its set so.
- Maybe it will collide but physics interaction on character is disabled making a different calculation.
So its really hard for me to say without actually counting it but Unreal performance wise (with my limited knowledge) it is pretty good already with phsyics. The thing is to how to control things gameplay wise since after all generally we are not making a simulation (some games are:) )
Using physics disables collisions.
Not sure what you mean by that, I don’t think I said something like that however if I said think I did say it wrong. Physics simulation requires collisions enabled. Besides that collision is just collision, its yes or no and ignore type of response to some other collision channels.
Depends on what you want to achieve. Generally its hand crafted functions that makes the movement good. In games we don’t want too much realism. You don’t want your awesome super duper ship to be destroyed by a tiny little meteor made out of a bizarre material. Or you don’t want to die in hardcore wow when you step to lava for a small amount of time
Let’s take a look at this sophisticated movement. Many things going on
- There is inertia of ships movement from side to side
- Forward accaleration is effected by ship forward and lateral movement enabling player to have control over the speed.
- Strafing moves affects the velocity like there is aerodynamics, on drift it slows down.
- There is almost no gravity in effect.
All things are physics as said in the end and they can be mathematically described in some code to achieve these results.
However if we would some real phyics features to make a simulation realistic as possible (some studios call hyperrealistic) it would be hard for player to have this experience since we have to talk around, fluid dynamics, then ofcource aerodynamics, air cushioning etc, probably bunch of more that I forget. I can talk around about why more if you like but its not the question you asked so skipping those. Still if that ship while passing close to some objects camera can shake, making it realistic and immersive while not effecting gameplay.
So when its just about having a certain control about what you want to do. There is no downsides. If its fun, its fun and whatever feels good when you play the arcade ship, do that.
Holy, moly, quite a complex subject behind a simple-looking facade. But I think I got it. I THINK😂
Ofcourse, knowledge is cumulative.
After a little bit pokin around in the engine code, internet searches regarding input vector and what happens actually in the movement component figured out some stuff that might interest you, which fundamentally confirms all the stuff I wrote in a hight level description. I did custom movements before in the engine for my game like wallruns, climbs, slides, hangs, wallrun mantles, normal mantes etc but never dig deep into base movement (Think its because of time allocation of the things I have to do)
Here is step by step breakdown also what happens in the engine when you add an input vector.
- Function runs on the frame. Think that function input like “Player wants to move this direction”
- This input is basically hold in pawn as LastInputVector then on the frame update its consumed.
- Then this vector actually converted to movement, there are some check functions on component like speed depending on what kind of movement will be made.
- These checks as commonly can be friction, slope angle, gravity etc. for calculate the actualy movement
- This is something I deal with and generally happens functions like
UCharacterMovementComponent::PhysWalking(float deltaTime, int32 Iterations)
which in a high level : Velocity,Delta Distance etc - Then you apply these basically with a function like
SafeMoveUpdatedComponent(Velocity * DeltaTime, UpdatedComponent->GetComponentQuat(), true, Hit);
- After movement happened the other things get updated like animations and so on
There is many aspect when a movement is tried, calculated and executed.
Like are running on ground and sliding as an example.. press crouch, you try to detect if player can slide (if speed, floor angle is available for sliding) then you calculate the actual slide with floor angle, enterance speed, boosted factor for speed for mass, max slide distance etc. and in the end calculate this movement and apply movemeent for each frame.. Since on the next frame there could be a rock that would stop player from sliding then movement mode changed, something else happens, or its a big rock, speed gets down already and slide ends, player goes to default movemeent mode which is walking..However eeach calculation is still derived from base physics laws.
Since movement is something very core at gameplay, it deserves a little bit attention and iteration. It can be overlooked but what I think movementcomponent code base is one of the nicest things in unreal.
Yes. I noticed how deep things can go when I implemented a simple crouch system, including a shortened capsule component, surface angle and all these things. Pretty interesting
if you have further movement questions, have worked on space movement in games. If you want something custom can handle it, like drags, landing, takeoff, steering, roll, camera changes, camera change and targeting etc. Let us know.
Looking forward to it,