- Home /
How do I go about making a 2d platform enemy ai
I want a 2D enemy AI that will follow the player and jump onto platforms. After lots of googling, I haven't found much if anything at all. I don't just want an ai the moves towards the player and jumps if a raycast hits or doesn't hit something, I want something like A* implemented. Can someone help me understand how I need to code it
Answer by jmailloux11 · Apr 18, 2020 at 11:52 AM
first, look if the player's position in the x is greater or smaller than the enemy's to make the enemy look in the good direction.
next, make it translate by something like 0.05f in the x axis.
then use raycasts to see if he is on the side of a platform to make it jump.
use Addforce in the y axis to make it jump.
add a tag in the editor so it's easier for the player to detect a collision with it.
and of course add a collider and rigidbody to the enemy.
Your answer
Follow this Question
Related Questions
AI & pathfinding for 2D platformer - how to approach? 0 Answers
Astar Pathfinding ai moves more nodes than it should 0 Answers
Enemy AI Help,Help on EnemyAI 2D 0 Answers
Enemy Moves Jitters when Supposed to Be Still 0 Answers
enemy AI patrol not working 1 Answer