Hello, so I am very new to C# any unity. but so far I have looked at some tutorials about AI, and I want to make a “horde mode” game for my first project. so far I have a gun script that works fine, the zombie (target) has a health script and a chase script that works fine. but I wanted to gather some information about losing this game I am making. The way I would like it, is if a zombie gets close enough to you, that it makes contact with the FPS controller, than the level restarts. Does anybody have any ideas for a script to allow this?
You can put colliders and rigidbodies on things but that is probably way overkill. If you take that approach there are plenty of tutorials about putting the right responder methods in each object, and the rules for getting collisions sent to you.
A much simpler approach is to just (in your zombie script) check the distance to the player every frame and when it gets close enough you call it a hit and reload, or go to a game over screen. It will be plenty performant for at least initial use.
Vector3.Distance will give you distance between two points.
Use the Unity Scene Manager to load other scenes.
Sounds great! Thank you so much
I’m going to disagree here. If you using the Unity standard controller then its already got a Rigidbody so just have to add a box collider scale it up to whatever distance you want and set it to be a trigger. If you got a horde of zombies do you really want to be checking there distance for each from the player every frame .With the collider no need for all that soon as any zombie touches it game over seems a lot simpler to me.