- Home /
How to detect nearby environement ?
Hi,
I am working on a small tactical game and I seek your advices to handle the stealth system. My map is divided into bare plains, tall grass areas and dense forests, and the player speed is altered by the type of environement he is currently in. What is the best way to detect his surrounding environement ?
Shoud I add an invisible circular mesh at the base of all my environement prefabs and use it to trigger a collider on the player object ?
Should I list all his surrounding objects with an OverlapSphere (http://docs.unity3d.com/ScriptReference/Physics.OverlapSphere.html) ?
Better ways ?
Thank you very much!
Answer by KdRWaylander · Jul 16, 2015 at 06:40 AM
Hi,
You can use the same solution as in here: http://answers.unity3d.com/questions/537783/changing-footstep-sound-when-on-different-surface.html
But instead of modifying the sound, you will change the speed !
Edit: 1. Keep in mind that if you're developing for mobile, raycast can be heavy, especially at each frame, consider InvokeRepeating(), coroutine, ... 2. Instead of checking the tag, i'd check the material directly (Renderer.Material) so you can also use the tag in an other script (like if you have moving plateforms, highground, lowground, ...)
Your answer
Follow this Question
Related Questions
Parameters at Startup 1 Answer
Project path settings C# 1 Answer
Load and Compilation time issues 0 Answers
Why the shader responds differently to Tri-color ambient light vs. Skybox lighting? 0 Answers
Texture size limit 3 Answers