x


Destroying a child object?

Hello. After a condition happens, how can I deactivate a child object of the object that the script is attached to? To help explain that better its set up like this (I want to make the "Shoot" Game object stop for a few seconds and then start again).

Player (Game Object) with the "Collide" script attached to it. --Shoot (Game Object)

Thanks.

more ▼

asked Nov 30 '10 at 11:37 PM

Tyler 2 gravatar image

Tyler 2
1.1k 211 246 264

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can just have a local reference to that child GameObject in your Collide script and then call gameObject.active = false

like this:

public class CollideScript: MonoBehaviour
{
  [SerializeField]
  private GameObject _shootObject;

  void OnCollisionEnter()
  {
    _shootObject.active = false;
  }
}
more ▼

answered Dec 01 '10 at 03:45 AM

Tommynator gravatar image

Tommynator
381 3 4 11

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5100
x414
x40

asked: Nov 30 '10 at 11:37 PM

Seen: 537 times

Last Updated: Nov 30 '10 at 11:37 PM