collision sensor

I have an empty that adds a cube from another layer. activated by the Q key at the moment.

How do i get the cube to ‘die’ or go away when it hits a certain object?

Give the objects that will destroy the object a property named something like destroyer.
Give your cube a collision sensor that detects when your cube is touching something with the property destroyer. Then link that to a AND controller and link that to an edit object actuator set to end object.

Ok thanks. but the problem was the killer has to be an ACTOR.

I have the same problem.

It seems that the collision sensor does NOT detect anything from dynamic objects whatsoever, be it set to respond to property or material, if the “killer” object is a dynamic actor it just doesn’t work for some reason.

One workaround would be to parent a non-dynamic object to the dynamic one, and set the collision sensor of the object to be killed to respond to that parented objects material/property.

Although the trouble with that workaround is that the “victim” object dissapears as soon as it comes in contact with the object parented to the dynamic object, therefore not giving your dynamic object the chance to bounce off the victim object first.

I need the dynamic killer object to bounce off the victim object and then have the victim object end.

If anyone knows how to do this please post.

try parenting the dynamic object to the non-dynamic object and make it invisible ,and put it where the player cant reach it.

You did not understand. Think of it as dodgeball, I need the dynamic ball (killer object) to move and hit a different non dynamic object (victim object), then I need the ball to bounce off the victim object first, and then I need the “victim” object to dissapear.

Right now the victim object dissapears as soon as it makes contact with the ball, I need the victim object to be there long enough for the ball to bounce back, and then dissapear.

Try giving it a time property…

I dunno, im still kinda a n00b at the GE

That’s ok, at least you tried. I appreciate that.

Actually I already tried using the time property like this:


t = own.time
 
if collision.isPositive() and t > 0.5:
    G.addActiveActuator(kill,1)

It seems that the time property starts ticking as soon as the game starts and not after the collision as I have expected. Everything would probably work if I could find a way to start the timer when the collision occurs, rather then when game starts.

Of course I would not need any of this if the collision sensor could detect dynamic objects :rolleyes: .

You can store the time when the collision occurs in a separate property. In the script you can substract the stored time from the actual time (t).

or

just reset the timer property to zero after the collision.

Hey Monster;

Thank you for providing me with theese options, they got me experimenting.

Actually I came up on an even simpler option:


if not collision.isPositive():
    G.addActiveActuator(kill,1)

It turns out that the collision sensor state is not tested at game initialization (for some reason), so all I had to do was make the killer object a little bigger than the bounding sphere of the dynamic object that it was parented to. This way the collision sensor state would be true until the dynamic object bounced back, giving me the option to activate the actuator when the collision sensor is in a false state (bounced off).