x


trigger enter not registering with child

Hello,

I have a target object with the On Trigger Enter (other : Collider) function{

. The trigger object is an arrow made of 2 parts, parent and child. if i have the trigger collider on the parent it works like a charm, but i would like the collider to be on the child which doesn't seem to trigger anything. any ideas why the collider will only work for the parent(yes i check the isTrigger box on both, Thanks

more ▼

asked Apr 21 '10 at 04:22 PM

ThumbStorm gravatar image

ThumbStorm
420 27 33 42

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

2 answers: sort voted first

I found there was a rigidbody on the parent and the child. So i took the one off the child and it works. That was a fun 3 hour headache!

more ▼

answered Apr 22 '10 at 04:18 AM

ThumbStorm gravatar image

ThumbStorm
420 27 33 42

@andyh81 lol...

Apr 27 '10 at 03:38 PM e.bonneville
(comments are locked)
10|3000 characters needed characters left

Hmm. I don't know, but I got some nice effects by following this answer to my question. It's kind of finicky, but what I ended up doing was (using triggers like you) was creating a couple of triggers for the terrain. Each trigger checked what colliders entered it. If the collider was an arrow, it told it to do a function which froze the arrow by setting the drag up high. I'll post the related scripts:

Script for the arrow:

var hit = false;

function OnCollision () {
    rigidbody.drag = 3000;
    rigidbody.angularDrag = 3000;
    hit = true;
    Kill();
}

function Kill () {
    yield WaitForSeconds(5);    
    Destroy (gameObject);
}

function Start () {
    Timeout();
}

function Timeout () {
    yield WaitForSeconds (2);
    Kill();
}

Script to put on the terrain collider/triggers:

function OnTriggerEnter (other : Collider) {
    if (other.gameObject.CompareTag ("Projectile")) {
        other.SendMessageUpwards ("OnCollision");
    }
}

Make two separate gameObjects, an arrowhead and an arrow-shaft. Then make the head a child of the shaft. Next, add a fixed joint to the arrow-shaft, and make it connected to the arrow head. Add colliders and rigidbodies to both objects. Then change the drag on either, making sure that the shaft has more drag, causing it to fall slower than the head. Finally, add the arrow script to the shaft, and the terrain script to the terrain colliders, which should be on empty gameObjects aligned with whatever you want the arrow to stop on. That should be it.

P.S. Is this answer overkill or what?

more ▼

answered Apr 22 '10 at 02:45 AM

e.bonneville gravatar image

e.bonneville
5.7k 100 116 165

I'm too far along into this to change my set up on the arrow. I have a model of an arrow linked to an empty game object which has gravity and then i animated the arrow's rotation. The good thing is that you'll never see the arrow hit the ground or have to stick into anything. Next time i'll try you way, it seems better. Thanks for the info!

Apr 22 '10 at 04:24 AM ThumbStorm

Took a break and tried your way of creating the arrow and it's pretty sweet!

Apr 27 '10 at 02:49 PM ThumbStorm
(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:

x1707
x986

asked: Apr 21 '10 at 04:22 PM

Seen: 1991 times

Last Updated: Apr 21 '10 at 04:36 PM