how do pawns and characters move

I was taking apart the source code and have a question about pawn movement. In GameFramework/Pawn.h, there is a function called AddMovementInput(direction, scale, demand); This function calls the movement components function called add input vector or else it calls Internal_AddMovementInput(WorldDirection * ScaleValue, bForce); The only thing the pawn movement component does is call the controlled pawn’s Internal_AddMovementInput(Acceleration, force), just like the pawn would be doing if it didn’t have a valid controller. Internal_AddMovementInput() adds the world acceleration to control input vector. ControlInputVector is used in the consume method, but I do not see where any of this is used. I followed the references as far as I could take each chain, but I don’t see where the ControlInputVector is used except in the Character.h class where it calls the ConsumeInputVector() method in tick component. How do pawns actually move? What am I missing?

It’s a very messy implementation. A while back I made my own movement component which had no need of most of the mess merged with the original (such as pathing). I put the code online here:

Pawn movement, what am I missing? - #6 by Roy_Wierer.Seda145

Follow that from its tick function.

with all due respect, I didn’t ask how to make my own. I asked how the engine does it. Full disclosure i did a search on the forums before adding my question to it. i already read your post.

2 Likes

Well, it does just like that. It’s the most simplified version of a functional movement component for a pawn there is based on UMovementComponent. Pawns and characters use more complex variants of the exact same thing which include code for pathing and other stuff.

It’s been a while since that post but if I remember correctly you cache a Velocity property, which is updated on tick to depenetrate / slide along collisions. You should see where that property is read on the UMovementComponent. With VS you can place a breakpoint on that line and debug your editor, you will see all the steps leading to the moment the velocity is read.

There is also a PawnMovementComponent, CharacterMovementComponent, they both are UMovementComponent with extra stuff in them to make it more complex for you. In the end it uses the same base just like the code I posted.

component inheritance:

afbeelding

1 Like

hmm. yeah. i read your work, which youre obviously proud of, and it still doesn’t answer my question. it’s very frustrating because this keeps happening. i asked this on other forums too… i asked a very specific question in no uncertain terms, and all i ever get back is examples from pedantics that explain how have, would, or should build their own movement component. for the last time, that’s not what i asked. HOW does the ENGINE! do it? where is the mechanism by which transform is updated?

it’s getting old. i know how to make my own movement component. with wall avoidance heuristics and everything. I know how i would do it. very frustrating. how does the engine do it?

so you have a pawn, and you give it a negative z value on it’s transform.location every tick, you get a gravity scale. a simple line trace can detect landscape, and the location of the actors z value can be se to the hitresult.location + capsule half height. you can take the cross product and the arc cosine of the dot product from the hit location of a sphere trace to get the angle of a wall relative to the actor location, and update acceleration vector can be offset by the angle created. etc. etc. etc.

I do not see. how the ENGINE. does what it does. with all due respect to your impressive work.

The CharacterMovementComponent moves the object, for Characters. Characters are a kind of Pawn. However, other kinds of Pawns and Actors use different MovementComponent implementations. For example, there’s a ProjectileMovementComponent, for projectiles. The simulation of each of these kinds of movement, is done in the movement component implementations.

Separately, the physical interaction (collision) with the world, is done by the physics system – Chaos, in UE5 – where the character actor moves the collision proxy, and reacts to collision callbacks from that system.

Finally, I feel that it’s OK to say “I read your code and it didn’t answer my question.” However, I don’t think you get to complain more than that, that it doesn’t answer the question – everyone here is trying to help you for free and if they feel that they’re hearing whining in response, they will be less likely to attempt to help next time.
If you see this same result in other questions you ask, perhaps you should look at the common element in all of those questions for some insight?

2 Likes

i see what you’re saying, but he wasnt trying to help. he was trying to show off his code. i dont care about this anymore. ill wait for jetbrains ai. that’s it. close this thread

Wow.

1 Like

Yeah, he asked for help, for something he doesn’t care about. Sweet move!

3 Likes

This is a case of you can explain all day but it won’t make sense until it can be copy pasted fully implemented. If you want to see how the engine does it, put breakpoints on “engine methods” in visual studio. Apparently that doesn’t make sense. I advice you get used to working with the VS debugging tools, breakpoints, and study the basics.