Break object lag

Hi all,

I have an object that on collision swaps to another version of the object with all the components seperate and each with a rigid body. The idea being it ‘explores’ into bits on collision.
This kind of works :slight_smile:

Essentially when the object is collided with I can tell the ‘dummy’ object has been spawned but nothing happens for a few seconds before it falls apart i.e. physics etc. happen.
Not sure what’s causing the delay.
The original object is ‘thrown’ i.e. applyforce and moves correctly so I assume any instantiated objects from that will inherit velocity etc.
Again, it seems correct; but the new object just sits and waits a few seconds before doing the business. Does the new object also inherit the script of it’s parent? (though this shouldn’t be an issue as there is nothing in the update function).
I also get double collisions i.e. although I destroy the original object the collision still happens twice. Tried destroy immediate but Unity just hangs on that. Is there anyway to tell an object is ‘dying’ and so be ignored in the collision handler? (or is it a Unity bug anyway?)

Cheers

You can try and create a collision mask. Disable original object => new object collision.

Hmmm,

Well,

Destroy(gameObject.rigidbody);
Destroy(gameObject);

Seems to solve the double collision issue. Anyone know why?; presumably a destroy on a rigid body gets processed sooner than the expected destroy game object i.e. it deals with the rigid body later… (seems wrong too me, destroy on game object should kill the lot and not process any components on this game object for collisions).

The ‘lag’ incidentally was caused by Blender exporting an animation component (what is default take?); and although there is no animation that I am aware of disabling this component seemed to get rid of the delay.

Though I have solved my issues it would be nice if someone with a greater understanding could explain WHY? :slight_smile:
I spend a lot of time ‘doing things Unity’s way’ but don’t know why! Lol!!!

Cheers

Actually scrap that solving the double collision ; problems back again :-((((((