using now relative velocity as influence for the ship part velocity when ship explodes
parent
4c1e016fc2
commit
a1999f9838
|
@ -68,7 +68,7 @@ bool ShipEntity::CollisionEvent (Engine::EntityBase* entity, vector3d point, vec
|
|||
Engine::EventBasePtr explode_event (new Engine::EventBase());
|
||||
explode_event->mEventType = EventShipExplode;
|
||||
explode_event->mEventUnsignedInt = mId;
|
||||
explode_event->mVector3d = normal;
|
||||
explode_event->mVector3d = mPhysicState->mVelocity - entity->mPhysicState->mVelocity;
|
||||
QueueEvent (explode_event);
|
||||
|
||||
return true;
|
||||
|
@ -81,7 +81,7 @@ bool ShipEntity::CollisionEvent (Engine::EntityBase* entity, vector3d point, vec
|
|||
Engine::EventBasePtr explode_event (new Engine::EventBase());
|
||||
explode_event->mEventType = EventShipExplode;
|
||||
explode_event->mEventUnsignedInt = mId;
|
||||
explode_event->mVector3d = normal;
|
||||
explode_event->mVector3d = mPhysicState->mVelocity - entity->mPhysicState->mVelocity;
|
||||
QueueEvent (explode_event);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -127,6 +127,7 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
|||
vector3d position = ship_entity->mPhysicState->mPosition;
|
||||
vector3d orientation = ship_entity->mPhysicState->mOrientation;
|
||||
vector3d velocity = ship_entity->mPhysicState->mVelocity;
|
||||
vector3d rel_velocity = event->mVector3d;
|
||||
|
||||
unsigned int i;
|
||||
mShipPartsEntityIds.clear();
|
||||
|
@ -135,8 +136,13 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
|||
Engine::EntityBase* part_sprite_particle = Engine::CreateEntity (GameEntityTypeShipPart);
|
||||
part_sprite_particle->mPhysicState->mPosition = position;
|
||||
part_sprite_particle->mPhysicState->mOrientation = orientation;
|
||||
part_sprite_particle->mPhysicState->mVelocity = velocity;
|
||||
part_sprite_particle->mPhysicState->mVelocity = vector3d (velocity[0] * (rand()/float(RAND_MAX)) * 1.7, 0., velocity[2] * (rand()/float(RAND_MAX)) * 1.5);
|
||||
vector3d part_velocity (
|
||||
rel_velocity[0] * (rand()/float(RAND_MAX)) * 1.7,
|
||||
0.,
|
||||
rel_velocity[2] * (rand()/float(RAND_MAX)) * 1.5
|
||||
);
|
||||
part_sprite_particle->mPhysicState->mVelocity = part_velocity;
|
||||
|
||||
part_sprite_particle->mPhysicState->mAngleVelocity = (rand()/float(RAND_MAX) - 0.5 ) * 100.;
|
||||
|
||||
mShipPartsEntityIds.push_back(part_sprite_particle->mId);
|
||||
|
|
Loading…
Reference in New Issue