- Home /
Creating interactive environment
Hi ! I want to create a game in which i want the certain environment props to activate when user is near them , just like in many stunt and raunner games environment objects start moving when player reaches near them , I can add scripts on them and enable or Disable them based on player distance but i was wondering is there a better way to aproach this ! As checking for update inside multiple objects in costly ! Thanks in advance !
Answer by Klarax · Jan 23, 2020 at 05:46 PM
to me, its either do the usual calc from object to player - something like:
float dist = Vector3.Distance(other.position, transform.position);
or use triggers which detects when a player is enters them.
void OnTriggerEnter(collider col)
{
}
Your answer
Follow this Question
Related Questions
How can I make an area/models? 2 Answers
How do I Create a Bush? 1 Answer
Standard environment asset 0 Answers
Best program to create 3D maps in? 1 Answer
How can I draw one black pixel in GUI 2 Answers