|
I am new to game development and I was just trying to at least make a demo or a full game of a tiny tower defense game. Anyways I was going to have some AI come out and then eventually reach their target at which they then disappear, However My script doesn't really work. What do you think I should do? I tried adding a disable script to my AI Once the AI completes the waypoints, but it doesn't work. It gives me two errors
EvilCube is the enemy AI that I am trying to disable, once it has completed the waypoints The EvilCube has successfully gone to the waypoint, but when I add the disable part it gives me several errors Here is the Script var waypoint : Transform; var speed : float = 20; var distanceToTarget : float = Vector3.Distance(transform.position, EvilCube); function Update() { var target : Vector3 = waypoint.position; var moveDirection : Vector3 = target - transform.position; var velocity = rigidbody.velocity; if(moveDirection.magnitude < 1){ velocity = Vector3.zero; if(distanceToTarget == 0) this.EvilCube.active = false; } else{ velocity = moveDirection.normalized * speed; } rigidbody.velocity = velocity; } Thanks for the help. By the way, I put the script on the GameObject "EvilCube" so in INSPECTOR I see the script, plus the waypoints and how fast I can set it, etc.. I am using JavaScript I want to simply disable the EvilCube.
(comments are locked)
|
|
If you want to disable the whole gameobject in the scene, you just use:
If you wanted to disable this script, but keep the object that had this script in this scene, you would say:
If you wanted to destroy the GameObject from the scene, you would say: Sorry for spamming. I just needed to know all the details. Thanks for helping me. +1 for the help.
Jan 03 '11 at 09:23 PM
Didymos
Well I read your answer and I decided to apply the first part "this.gameObject.active = false" and it worked. Best Answer.
Jan 03 '11 at 09:30 PM
Didymos
(comments are locked)
|
