How to make a 2d enemy move toward their rotation

Hey!, so I have a 2d enemy which is floating currently and i have a find look at rotation node hooked up to a set actor rotation and I need to be able to move the enemy to where it is looking which in this case is the player.


the rotation works perfectly but i cannot seem to add movement properly with the add movement input node as it just moves it to how i set it not to where the rotation is.
Thanks

Hey there @PatyPotato!

For simple enemies, try using the MoveTo (or SimpleMoveTo, try both) node!

It will require the input of a vector, but you can just use that “get actor Location: Player Character” as the input :slight_smile:

If you want to get extra stylish, you can use a line trace by channel to have the enemy only move towards the player if they can see them!

I have a linetrace so i can get the players location even though i know i can use get player character - get actor location because the move to and simple move to werent working but that doesn work either.
I have got something that moves the enemy to the left and right if im on the respective sides but i just cant get the flying enemy to go down or anything on the y axis at all
thanks for the help so far

My enemy movement code:


the green line is delta seconds from the event tick

It’s a 2D Enemy that flies… Are you sure you don’t need to be having it move on the Z axis for flight path? Depending on how you have it set up, it should be Y=L/R, X=Depth, Z=height or X=L/R, Y=Depth, Z=height, but looking at this code that doesn’t much matter.

Can you possibly get video of what the issue is in action? And that print string is firing, correct?

yes the print string is firing, also its not as much as it flies it just doesnt have gravity which could be messing it up.
Here is the video:

If your wondering why it stops moving after being far away it has an overlapping sphere that just stops movement if its too far away so its just a simple agro system.

also sorry for bad video quality and beeping it was just a random video software i downloaded for this, let me know if its not a supported format because idk if it is (its mp4)

So the video is saying it’s an unsupported format, BUUUT I think I found some things to try: Somebody else had the same question here and had a FEW options to try! Give these a shot!

I couldnt work it out from this but I did get the solution!!! from a kind man in the discord
he got the math wrong or it just didnt work for me so i changed it :}


`

The line going off screen goes to the tick event

2 Likes