Character moves towards cursor

Goodday!

I want to make a topdown-view game where the character follows the mouse cursor. I’m quit new to UE4 so some visual explaining would be great.

Open the top-down template and remove this from the Player Controller BP:

Done.


I’m quit new to UE4 so some visual explaining would be great.

The movement in the template revolves around this function:

  • we check what is under the cursor, the Hit
  • if that location is further than MinClickDistance, we ask the character to traverse there every frame onTick
  • the character finds their way around obstacles using navMesh that was automatically generated for the level geometry:

2 Likes

Awesome, thank you!

1 Like

Little issue. I already had alot of progress in another project. I tried copying the BP’s from downview to my other project only that messed things up. Do you have any video or documentation I can follow to re-create the BP’s from scratch?

Do you have any video or documentation I can follow to re-create the BP’s from scratch?

Yes, it’s all in the template. You need 3 things:

  • navMesh
  • character
  • location

It literally boils down to:

1 Like

Okay, so I made that, this:

And a gamemode but It’s still not working. Any idea?

This looks nothing like the script I posted… Nowhere above are you telling the character to actually move.

That’s the script from the Character BP. I figured I would need that as well.

The script you posted I copied in the player controller.

I have this now:

Controller BP

Character BP

Gamemode BP

No Idea why it isn’t working.

Ensure you have navMesh. Ensure you’re using the GameMode.

Is the code in the Controller running?

Are you possessing the character?

I forgot to make the navMesh. Thanks!

Only problem I’m encountering now is that the character isn’t rotation towards the cursor. Any Idea’s?

Select movement component in the character BP - Orient To Movement or something like that

Didn’t do much. Just made small frame skips when moving the cursor from left to right.

Forgot to disable UseControllerRotationYaw. Now it’s just spinning really fast.

How would I determine the speed of the rotation?

[Edit:] What I mean by this is that the rotation is very sensitive.