Games and Prototyping: Collision Detection From Enemy Controller
In our previous article, we focused on Enemy Movement, using a Vector Direction method Destination — Start and Ping-Pong operation for the enemy to go between two points in our world.
We will now add logic for collision detection to our enemy controller script.
When we type in class name to search for Collision, we want to access the OnCollision methods.
Here we can access our collision properties within the OnCollision function.
Since we want to collide with our player controller, we need to get collision component and access collision that we hit, and decide how want to detect the collision. We will detect collision by collision object name, which would be Player.
We then call our Destroy() method to remove our collision object the enemy hit from the scene.
Now we have the ability to destroy our player controller.
Next, we will finalize our project, by creating a win condition once we reach our goal.