I want to change a Boolean on multiple or a single object when its within a certain distance. Im new to c# and I’d much rather program this game in c#. So i was thinking of having some variables like these.
public int Radius = 1;
public GameObject ActivatedObjects = GameObject.FindWithTag("activate");
Could I set up a function to where it finds game objects with the activate tag (activated objects variable) within a certain distance (radius variable) and than have a Boolean in those objects that were found and change it from false to true or the other way around. Much help is appreciated.
I often use trigger areas that activates objects, this way you won’t have to worry about clutching up the overhead to much. While the objects are active I check for a distance > player trigger area (using sqrMagnitude), if it is then disable their demanding components.
This require rigidbodies though, if your game doesn’t use physics then run a invoked coroutine checking for sqrMagnitude on the objects.
Thanks! Not even my question but the idea of trigger areas will help me soon. =)
Thanks! Not even my question but the idea of trigger areas will help me soon. =)
– Essential