|
Hi there! I need to know how i can repeat this Script with a Boolean. So there's a Speeder and when it comes near the Location point, it'll be activated ONCE, and then it ends. So how can i reacivate this Script when i come near the same Point a Second Time? I receive this: Expressions in statements must only be executed for their side-effects. But i don't know why. var distance = Vector3.Distance(speeder.transform.position, transform.position); if distance < aggroRadius) { Instantiate (TestLoc,transform.position, transform.rotation); Instantiate (shadow,transform.position, transform.rotation); Destroy(gameObject); } } else { distance > aggroRadius; } }
(comments are locked)
|
|
Okay, so it doesn't repeat the Script and only one Locator is working, but ignoring the Aggro Radius. When i press Play it spawns, whereever i am.
(comments are locked)
|
|
So it does not Run anyway. Nothing spawns, nowhere. So isn't there a Possibility to do this Loop with a simple Boolean true/false thing? Something like this? So this does'nt repeat it if i leave the Place... but maybe you can help me?
(comments are locked)
|
|
Firstly, if your looking for distance of the speeder, why not use a Sphere Collider? Then you could just use OnTriggerEnter and OnTriggerExit however, if you must do it this way from some reason Also, like what was said above, DestroyObject... this kills the gameObject.
Jul 14 '12 at 05:38 PM
Avaista
(comments are locked)
|
|
Thanks a lot! i've now this: Now i receive an Error: UCE0001: ';' expected. Insert a semicolon at the end. But i can't see any missing Semicolon there.... could that be a Bug? Your original code is uscript, and Aviasta's code is C#. For example, if you look up I think it might help if you think more about what is supposed to happen in the game. If the code above worked, you could stand just at the edge of the area, moving a tiny bit forward and back to keep spawning shadows. Is that what you want?
Jul 15 '12 at 03:27 PM
Owen Reynolds
You should replace with I think, I do not use JavaScript. Also, after your while loop in the coroutine function, you have a semicolon. In C# this would result in an infinite loop, and I am 99% sure it will in JS as well, once the condition is true. If you get it working, like owen said, test it out and see if it has the behavior you want.
Jul 15 '12 at 04:17 PM
Avaista
(comments are locked)
|
|
What i need to do is only a repeat when i reach the point one more Time. So they spawn on a track. 6 Locators are on it, and it must be, that they spawn again and again, whenever i pass the Point. (i've used Javascript. Don't know another.)
(comments are locked)
|

The code kills itself (
Destroy(gameObject);) so you can't activate it twice.Your last para: the final
else { distance>aggroRadius; }isn't anything. If you don't want to do anything whenisActiveis false, then don't do anything -- don't have an else.