I have two scripts added to my enemy, a path and another for him to start chasing me and I want you when you’re close to the script path is disabled for the script is activated and chase away again when the script path is activated again.
Please if you can help me I thank you!
1 Answer
1
your description is really confusing… so i’m going to go by the title question.
to disable other scripts just use the GetComponent function then set enabled to false.
to get distances you can use the 3 dimensional distance formula or use the Vector 3 Distance function.
some pesuado code for you;
myscript = gameObject.GetComponent("otherScript");
if(player is near path) {
myscript.enabled = false;
{
else {
myscript.enabled = true;
}
http://library.thinkquest.org/20991/gather/formula/data/270.html
I don't know if i quite understand your question but if it's just about disabling/enabling a script from another script then you can use something like this: somegameobject.GetComponent("OtherScript").enabled = false; // or true to enable somegameobject is the gameoject the otherscript is attached to (transform.gameobject if it's the same) Here is another question with a similar topic: http://answers.unity3d.com/questions/26844/enabledisable-specific-components.html (Next time please search on unity answer or even google before posting a new answer)
– ExTheSea