How to use MoveToActor with APlayerController?

Thanks a lot for the info : )

but the collision is ignored and I can walk through it, so it needs to have another reason, maybe you have a different idea.

Hello,

the problem is that my character stops 45 units away from the target actor, but there is no AcceptanceRadius in SimpleMoveToActor. So I would like to use MoveToActor from the AAiController(ore a similar function) with the APlayerController. I also would like to learn a bit more about AI and didn’t find a good post, so I hope someone could show me one : )

There Is another question that has a similar topic so I hope to get a answer here too:

It would be nice to bind a function that gets called when the character gets to his destination but sadly I don’t have a idea how to make it.

If I didn’t provided enough information then feel free to tell me.

Thank a lot for any help,

Tobias

This is what I mean He should stand nearly in the middle of the cube:

193571-not+close+enough.png

Hi,

You can check the horizontal distance between your character and the target. This will give you a float distance (Current Distance) between the two. You can use this distance to do any useful things you want.

The character won’t move to the middle of the cube as it might be an obstacle in the navmesh blocking collision for the player capsule to move into it.

As far as learning AI is considered. You can start with EPIC’s official documentation on it at https://docs.unrealengine.com/latest/INT/Gameplay/AI/

And there are a lot of video tutorials on the official YouTube Channel. One such playlist. There are a lot of them in their channel and also lot of good community based tutorials out there.

Simple move to actor doesn’t move the actor to an accurate location and doesn’t have an acceptance radius. So you can use it to move your actor closer to your target but not to a pinpoint location.

If you want your character to move accurately to the target, you can either use aicontroller ‘MoveToLocation’, but for controlled character its too much work.

What you can do instead is check for the horizontal distance between the two on tick and as soon as it comes within a certain range (say 50 units), do an interp from current actor location to target location or use a timeline to lerp with even more control. There are lot of ways depending on what you wanna achieve.

Hope this helps.

Cheers.

I would spawn an AIController to control your character and move him by taking a reference to his AIController and calling the more robust MoveToActor. Your actual possessed pawn would be a floating camera pawn that attaches to him if you want that sort of thing.

It’s easy to know when he reaches his destination because there is an event on the AIController called something like MoveCompleted. It outputs a variable that tells you the reason he stopped so you can respond there.

Really nice idea but I prefer the other idea, thanks a lot for you help it is really nice : D

1 Like

thanks this a nice idea thanks a lot : D

no problem. Glad that you got your problem resolved.