Tip:
Highlight text to annotate it
X
To create an enemy, duplicate the player (Ctrl+D or with the menu)
Assign to the enemy a new Material
To allow the enemy to pass through the wall we need to set the IsTrigger property of the Collider component to true
The Collider will no more be repulse by the floor, so we have to handle collisions ourself
To handle the forces : set the IsKinematic property of the Rigidboby to true
The enemy is not affected by the physics engine
"LlEnemyBase" will be the base class for all our enemies
Make some OOP
We manage the main enemy behaviour with a boolean telling us if the enemy has entered the battle area
Handle triggers by overriding : OnTriggerEnter(KnCollider collider)
As for collisions there are : OnTriggerStay(KnCollider collider) and OnTriggerExit(KnCollider collider)
When our enemy exits a "Wall" Trigger, he enters the battle area, and so we let the physics handle the object
Set the start position of the object to the floor regarding to its Box Collider
When the enemy hits a wall, he turns