x


Can I have a OnTriggerEnter apply to a specific child?

Greetings,

I would like to know if it's possible for the function OnTriggerEnter to apply to a specific child of the object or does it absolutely need to be on the object that use it.

more ▼

asked Dec 19 '11 at 04:15 AM

Oninji gravatar image

Oninji
332 43 47 50

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

1 answer: sort newest

if the collider that u use as a trigger is on the child and the script with OnTriggerEnter function as well then you can use it !!...

if it has to be on parent Gameobject for sure then u can attach the script to the parent and from the parent's OnTriggerEnter you can call a function on that specific child using SendMessage function

more ▼

answered Dec 19 '11 at 04:23 AM

flamy gravatar image

flamy
3.6k 5 12 38

Actually, from the parent script I want the OnTriggerEnter to apply to the collider that reside within the Children.

I already know I can send a message from a Children to the Parent, but I'm trying to keep a clean and efficient code. So I would like to avoid creating a new script if not necessary.

Dec 19 '11 at 04:34 AM Oninji

hmm OnTriggerEnter would work in the script, if it is attached to the gameobject that has collider.

As far as i know it is not possible without attaching a script to the child!! anyway take a look at Raycast, ma be come up with a logic. I am too sleepy to think of anything lol

Dec 19 '11 at 06:10 AM flamy
(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:

x427
x356
x51

asked: Dec 19 '11 at 04:15 AM

Seen: 871 times

Last Updated: Dec 19 '11 at 06:10 AM