2D Enemy AI Help Please!

Hey guys, I am new to UE4 and A friend and I are trying to make a 2d side scroller game. I need to make a AI for the enemies to follow the char. when close and attack when in range to hit. Kind of like how they do in the game Risk Of Rain. I have tryed to find videos on how to do this, but I can’t find any. Can someone please help me on this.

Hello,** TrevKro**, can I ask what type of engine you are using? Are you using the UE4 Creator, or the 2D Paper. I would love to help.

Thanks for the help. So I started working on the trigger boxes and i came up with this. Everything seems to be working, Including the flipbook change, but the enemy is not moving at all. Do you know what i’m doing wrong?

I’m still confused. Could you give me a example like a picture on how to set that up. How do I make the enemy move toward the player?

Ok I got that to work, but I want to speed him up, and he just goes through the ground hes not standing on the platform hes just floating. How would I go about fixing that? What vector would I break for him to just go on the X, no matter which one i break he seems to go in a diagonal direction even though he is only receiving the X.

Alright, so in the physics on my enemy it has Simulate Physics grayed out. How can I get it to get it where it’s not grayed out?

Here are my components

components.PNG

Here are my Collisions

flipbookCol.png

Here are my Physics

I can enable physics on the triggers but not the flipbook. I’m not sure what I need to enable to be able to enable the physics.

Ok so I ended up switching the hitbox and the flipbook to add the physics, but he seems to fall and can’t fall off again. Do you know a fix for this? Also when the trigger box collides with anything, like the ground it triggers. I am useing the event OnComponentBeginOverlap. Is there a better event to use where it only triggers when the player walks into it?

Ok so I found out that I only had the flipbook to the addoffset and the physics is on the hitbox, but now the flipbook, and both triggers are moving at the same speed but the hitbox seems to have some drag. Do you know why this is?

[video]https://gfycat.com/KindHeavenlyKillerwhale[/video]

Ok, So I think the last think is how to make him rotate the right wait when running. Like if hes running left have him face the left. How would I go about doing this?

Yep, did that. How would I go about making him rotate the right wait when running. Like if hes running left have him face the left?

Could you provide a picture on how to so this please?

Nvm I figured out it was suppose to be the get componet velocity, and it works. Thank you so much for your help

One last thing. When he is rotating it kindof glitches and sometimes faces the wrong way, like when I’m running to the left it should be a negitive number but is still positive. I assumed it was because of it being really small numbers(.000742) I tryed multiplying it but it really didn’t fix it. do you know how to fix this or a better way that doesn’t do this?