How can I improve this AI script?

Hi, I am making a game in unity, and have an enemy that follows the player. the script i used is the script given i this link.

the problem I am having is that the enemy floats towards the player, despite being a rigidbody object. It doesn’t follow any physics and goes through walls and floors. How can i edit the code to prevent any of these from happening?? any help will be appreciated,

-Blackichan

2 Answers

2

Add a collider to the AI object
(Component>Physics>Box Collider)

I tried adding a collider, but it didn't make any difference. Is there anything i could do to the code that would fix anything?

AI coding is not easy, if you are new to unity I would keep my distance until you are more experienced. This “AI” script you got only moves and rotates the object. It is not possible to modify this script to do what you want. You would need a completely new script.