Need more clear explanation of how MoveToActor and RequestDirectMove work together

This has been very confusing lecture for me. You mentioned that MoveToActor will generate a vector for RequestDirectMove. But in the coding, neither of those methods implemented in TankAIController or TankMovementComponent called on each other in any with through visible coding. It works, so I assume in the deep game engine, MoveToActor is triggering some sort of code to pass value to RequestDirectMove. But how does it know what the name of the movement component the actor has? MoveToActor only returns an enum and not a vector by itself. I believe there are some practices of this way of coding needs better explanation and how to find out through documentation that this should be the way to use them. Also, because of that, I think the challenge isn’t well thought out, because this has never been done before and can’t reach a working solution without checking answer first.

1 Like

Thanks for this feedback. We did delve into the engine quite deeply here, and I purposely didn’t go too into depth as not to scare anyone off.

I hope you can get pas this bit “on faith” and enjoy the rest of the course

You can easily view the definition of MoveToActor() by right clicking in Visual Studio and clicking Go To Definition. If you dig through you will find your answers.

Since you want to be so verbose, in line 932 of PathFollowingComponent.cpp, you will find your call to RequestDirectMove(), which it calls on the referenced movement component. On line 1185 of PathFollowingComponent.cpp you will find where it gets the reference to our TankMovementComponent via FindComponentByClass<UNavMovementComponent>().

So the execution flow is something like this:
MoveToActor() > MoveTo() > RequestPathAndMove() > RequestMove() > PathFollowingComponent->RequestMove() > SetMoveSegment() > Move segment is now updated. Meanwhile the PathFollowingComponent Tick is executing > FollowPathSegment() > MovementComponent->RequestDirectMove() > Tank moves accordingly.

So yes, all of this does indeed spit out a vector for our tank to move in, and that’s all that needs to be known at this stage in the curriculum. If you really want answers so badly just dig through the source code. I found all of this in like 5 minutes.

2 Likes

Thank Ryan, that answered all my questions. I just find it odd that I can not find UE documentation that explain this in detail. Do all UE programmers learn by digging engine code instead of going through API reference?

If there’s no documentation, then where else are you going to look?

I think that if they were to document for every possible execution flow of every method in the entire engine, they would be writing it until the end of eternity! The documentation is like an automobile owner’s manual. It will tell you in detail about every button, feature, requirement, and how to use all of it individually. But if you wanna drive down the highway on cruise-control with the top down blasting Gwen Stefani at full volume, you’re gonna have to use what you know to figure that out on your own. :grinning:

P.S. When you get the hang of digging through someone else’s source code and making sense of it, your ability as a programmer skyrockets.

1 Like

I had the the same moment of bafflement !

Normally I just google it but am unable to find any link between (in this case) these 2 functions or any suggestion of how I would come to know. Code is daunting to me so looking through the engine source files is really intimidating !

I suppose the fact the engine is vastly complex and so flexible means there are many ways or uses to do any one thing so official documentation doesn’t necessarily impose (or exist) one way or another.

Thanks everyone for the helpful discussion.

I concur, its cool working backworks to see how its done - but how would one know how to solve a similar problem in a different flavour. I guess its not within the scope of this course at the mo

Privacy & Terms