enemy ai going to player

im doing a fps with the fps tutorial but i whant to add a new enemy. the one i whant to add is a cube that try to run into the player when it get in range and when it hit him it get replace by a explosion that will damage the player. i know how to make the cube by an explosion when it hit the player but i dont know how to make the AI. plz help :)

"Berg Zurg Arcade" google it, they have hundereds of tutorials on this kind of stuff also youtube "basic ai in unity" that will help also. Good Luck

well if it can be really simple, you can do something like: `if(Vector3.Distance(player.transform.position,enemy.transform.position) < certainDistance)

{

enemy.transform.position = Vector3.MoveTowards(enemy.transform.position,player.transform.position,speed);

}`

certainDistance is a distance obviously. speed is the speed of the enemy. should be Time.deltaTime * 10 or something like that if you want it to always have the same speed.