- Home /
How to make object correctly disperse into physical children on impact.
Good day. The thing i am trying to achieve lookes pretty simple and straightforward.
Say there is an object consisisting of several children - cubes that is. All of them have rigidbodies, colliders and everything. They are set to isKinematic.
a bullet is fired (say a cube also) with high mass.
On impact with this object i want to make all these children to non kinematic so that it would look that this object is destroyed and all the pieces are flying all around.
and i do that - pretty simple - on impact with one of the children script makes all children non kinematic.
HOWEVER. the problem i am having - SOMETIMES - the bullet hits the object, looses all velocity and falls to the ground. the same goes for this object i am trying to destroy. pieces do not fly all over- they just fall togeter to the ground. - that is being that collision is detected, but the impact of mass and velocities is not accounted for.
i understand that is hat happens:
ideally is should work: bullet flying - collision - everything set to physical - collision physics calculated - success
in this case - this is what happens: bullet flying - collision - collision physycs calculated(that is being the same as hitting the unmovable wall) - everythyng set to physical - not good at all =(
i have managed to work around that by moving the bullet to position it had at previous physics step before collision - with the velocity it had at the time.
this works perfectly, byt as you can imagine looks unnatural as bullet teleports slightly back on impact if you look carefully.
Is there a more elegant way around it? How wold you achieve this?
sorry for my english - not a first language