Quantcast
Channel: Answers by "doomprodigy"
Viewing all articles
Browse latest Browse all 90

Answer by doomprodigy

$
0
0

If I get what your saying. You want to disable a object and enable the rest. use SetActiveRecursively if true it will enable the item/activate and that object children aswell. if false it will deactive the object and it's children.

If you want to only disable one part of the object use active.

Heres an example. C#

public GameObject currentlyenabled = GameObject.FindWithTag("enabled");
public GameObject currentlydisabled = GameObject.FindWithTag("disabled");

//After your collision script enter this
currentlyenabled.SetActiveRecursively(false);
currentlydisabled.SetActiveRecursibely(true);

JavaScript

var currentlyenabled = GameObject.FindWithTag ("enabled");
var currentlydisabled = GameObject.FindWithTag ("disabled");

//After your collision script enter this
currentlyenabled.SetActiveRecursively(false);
currentlydisabled.SetActiveRecursibely(true);

Using the tags keep it a bit tidy compared to having multiple game objects going on and off just tag the one enabled with "enabled" and all the ones that are disabled currently "disabled".

If your asking how you can find and turn something on/off that should work. If your asking to find something inactive and access scripts from I am fairly sure you cannot do that, but what I would do in that case is turn that objects render off.

I am a bit stumped on what your asking.

Peace,

EDIT: Did you test it with the tag method that I posted before instead of just using Gameobject.Find ? If that does not work another method would be to make a Gameobject variabled in which you then manually put what object it is into the inspector and then SetActiveRecursively it (this will work).

Example C#:

public GameObject male_portrait;

male_portrait.SetActiveRecursively(true);

Example Java:

var male_portrait : Gameobject;

male_portrait.SetActiveRecursively(true);

Viewing all articles
Browse latest Browse all 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>