video thumbnail 12:59
Unity Create a Game Series (E03. enemies)

2015-09-19

[public] 82.0K views, 1.26K likes, 9.00 dislikes audio only

In episode three we create an enemy to chase the player around.

FAQ:

Q: QueryTriggerInteraction does not exist in the current context?

A: Upgrade to Unity 5.2+, or leave that parameter out and turn on raycast triggers in the physics settings (edit - project settings)

Q: Why use raycasts instead of OnTriggerEnter to detect projectile collisions?

A: At very high projectile speeds OnTriggerEnter might not be called (since the projectile would be in front of enemy one frame, and through it the next). Raycasting just makes sure that collisions will work no matter the projectile speed.

Source code:

https://github.com/SebLague/Create-a-Game-Source

Follow me on twitter @SebastianLague

Support my videos on Patreon: http://bit.ly/sebPatreon


Game development tutorials. Support my videos on Patreon
https://www.patreon.com/SebastianLague
give it a nav mesh agent component
/youtube/video/UnPZyFjUvOM?t=120.04
start setting up some collision detection
/youtube/video/UnPZyFjUvOM?t=430.59
collide with trigger colliders
/youtube/video/UnPZyFjUvOM?t=602.51001
destroy the projectile
/youtube/video/UnPZyFjUvOM?t=651.5