Hi, I continuing my work on my game using this engine and I have few questions about contacts detecting and impulses.
In my game players fight with each other. So, one of the ways to destroy opponent - shot a rocket and hit enemy. I have implemented this functionality using ContactCreated event. Then player launch rocket I just add event listener to this rocket
Code: Select all
CharacterController.Body.CollisionInformation.Events.ContactCreated += ProjectileOnContactCreated
and then in this function resolving contact. I working with some logic stuff there (checking health, if player dead and some other things), but anyway, at the end I delete rocket from space and remove player - if it dies :
Code: Select all
var CharacterController = ((BasePhysics) Player.Physics).GetCharacterController();
Space.Remove(CharacterController.Body);
And then user click button to respawn again, I respawn him :
Code: Select all
var CharacterController = ((BasePhysics)Player.Physics).GetCharacterController();
CharacterController.Body.Position = GetRandomRespawn();
Space.Add(CharacterController.Body);
The problem is - then player respawned - he is pushed back, right after appearing. I assume that is is some kind of impulse or something else, after collision with rocket. Because after death I remove player from space - it removes him from simulation loop. But then I add him back - he is active again and system immideatly start to process impulse data from prev collision. Is there any way to fully reset user impulses, velocity's and other stats to make him stand still after respawn? I think that problem is in physical effects, because then I kill player with laser (wich doesn't push player back then hit), killed player respawns well.
Thanks.