How do I have my character turn and face the Actor I've click on?

Hi. Been trying to do this for literally 4 hours and I feel I’m close, I just can’t figure out the rotation part. I’m using the TopDown template and have attached a pic of my BP.

I’d suggest getting the Character world location and the Actor world location… plug both these location vectors into Find Look At Rotation node… this will give the rotation needed.

Then you can use Rinterp or a lerp and timeline or something to transition your Character from current rotation to target rotation… you might do this using Set Control Rotation or Set Actor Rotation on your Character

Hi! Thanks for your help. From how this new BP works, I think I’m 95% of the way there. My character currently moves to the actor, but only turns and faces it when I click again. Imgur: The magic of the Internet

The interp speed was 3 before, and I had to click loads of times and it’d rotate slowly each click, until it was facing the actor. Now, it’s 0, but only turns to face the actor once it’s beside the actor and the actor is clicked again.

Is it possible to have it so I click once, my character runs to the clicked actor, then within X range it faces actor?

your welcome! everything you ask for is certainly achievable… here’s a few thoughts:

  • the reason your Rinterp is only working for a moment, when you click on it… is because it only fires ONCE… you need your Rinterp to be on a running thread (i.e. like Tick) so that it will do the full rotation in a normal smooth sequence. Personally, I’d set up a boolean on event key pressed, and move the remainder of the function to a Branch on Tick… (yes, there are more performance-efficient ways to do it, but this is just to get the logic sorted out first as a prototype). So when key pressed = true… perform the following operations

  • your second question, just get the distance between your character and actor and Branch, when < your intended distance, perform the rotation as above

Hey, thanks again. Imgur: The magic of the Internet

So, I think I did what you suggested, but I now have another problem. Something in this part of the blueprint is making my character face the wrong direction when running. And also, when moving, my mouse click doesn’t go where the cursor is. I’m assuming that if I fix the first problem, the 2nd problem will fix. I just can’t figure out what’s going wrong.

Thanks again for your help.

welcome! I took a quick scan over your BP: are you trying to get your character to move to another actor, or move to the location of the mouse click?

I’m trying to get my character to move to another actor. It does indeed currently move to the location of the click.

I’ve got it to move to Actor, not the click location now. So, I’ve pretty much got it exactly how I want it, except for a few things. I moved my BP to the TopDownController, as that already had a system to move, then I just added my rotation part of the BP to it. Imgur: The magic of the Internet - Imgur: The magic of the Internet

1: When my character is standing still and an actor is behind me, my character won’t turn around and face the actor, even if I click again.
2: My character won’t always face the center of the actor. It moves to it, but stands beside it, or runs around to the other side of it, instead of the side closest.
3: The landscape is considered an actor? So when I try to click on the landscape to move, it instead sends me running across the landscape. I can’t block clicks to the landscape, because I need it to move, so I’m sort of confused as to how to proceed.

Again, thanks for your help. :slight_smile:

your welcome :slight_smile: question 2… I think your character is trying to occupy EXACTLY the same space as your actor, this is why he sometimes runs around to the other side. Set a cutoff distance, so your character will stop
question 3… a few options, including Branch if the actor is a landscape and do one of the following

  • move to the clicked location on the landscape instead of the landscape actor location
  • or do nothing and wait for the player to click on another actor
    question 1… I’d wait until the above two are fixed then we can see if this is still an issue

So, I’m stumped with 2 things from what you suggested. I’ve added some stuff to the first branch, which in my mind does what you suggested, but during play, it does nothing. I also tried it with a Get Distance to node, with the same float hooked into it. Also, I’m not sure how to go about creating another branch for the landscape problem (where to put the branch and how to get a reference to the landscape as I can only see “Cast to Landscape”.)

Ty again :smiley:

I understand…

ok, to test question 2… turn off your character’s collision, see if he tries to go inside your target actor and doesn’t run to the other side

let’s fix this first

Yep, it runs to the center

good, so now we know why “2: My character won’t always face the center of the actor. It moves to it, but stands beside it, or runs around to the other side of it, instead of the side closest.”

so the solution to 2 is to stop the character (with collision on) before he tries to get into the center of the other actor. There are a few different ways to do this… you could use a Move To Actor (with the nav system), you can use Vinterp or a Timeline&Lerp… with different techniques, you have different options of stopping before the collision, or using the collision to turn off the movement (preventing the weird behavior)

Unfortunately, I couldn’t get it to work and my BP’s are starting to look like bad spaghetti, so I’m just going to have someone on the Looking For Work forum do it for me, so I can progress with other aspects of my project. Thanks for your help. :slight_smile:

yeah, I do understand… especially if you are using humanoid characters… it might be worth getting into UE4 nav system… what you are aiming for is certainly doable in an elegant way… there are a automatic functions for your needs and a bunch of tutorials on YouTube.