Every thing up untill now is working as should, I think.... My little cubes drop on the ground and do their physics thing and all.
But when I run the next method Bepu starts to act crazy, the shockwave works but after that.... My little cubes start to jump around with almost no end, new physics box entities drop almost all trough the floor and other wacky things happen.
Code: Select all
public void ApplyShockToAllEntities(Vector3 shockWaveOrigen, float force, float forceDistance)
{
float distance;
foreach (Entity e in space.entities)
{
distance = Vector3.Distance(shockWaveOrigen, e.worldTransform.Translation);
if (distance < forceDistance)
{
e.linearVelocity -= Vector3.Normalize(shockWaveOrigen - e.worldTransform.Translation) *(force * (forceDistance / distance) );
}
}
}
Code: Select all
if (input.GamePadState.Buttons.B == ButtonState.Pressed && input.OldGamePadState.Buttons.B == ButtonState.Released)
physicsManager.ApplyShockToAllEntities(player.Position, 25, 125);
Thanks
Greets and sorry for my shitty english,
Nostromo