PlayerDeathSystem is now working well. Changed so the model is oriented correctly. Changed so camera is behind the player. Copied the current animation and froze it.
This commit is contained in:
@@ -8,12 +8,13 @@
|
|||||||
<Speed>0</Speed>
|
<Speed>0</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Lifetime>
|
<c:Lifetime>
|
||||||
<Lifetime>8</Lifetime>
|
<Lifetime>4</Lifetime>
|
||||||
</c:Lifetime>
|
</c:Lifetime>
|
||||||
<c:ExplosionEffect>
|
<c:ExplosionEffect>
|
||||||
<TimeSinceDeath>0</TimeSinceDeath>
|
<TimeSinceDeath>0</TimeSinceDeath>
|
||||||
<ExplosionDuration>8</ExplosionDuration>
|
<ExplosionDuration>4</ExplosionDuration>
|
||||||
<ExplosionOrigin X="-60.9153252" Y="0.767338753" Z="-76.4729843"/>
|
<ExplosionOrigin X="-60.9153252" Y="0.767338753" Z="-76.4729843"/>
|
||||||
|
<Velocity X="0.5" Y="0.5" Z="0"/>
|
||||||
</c:ExplosionEffect>
|
</c:ExplosionEffect>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||||
|
|||||||
@@ -43,38 +43,39 @@ void PlayerDeathSystem::Update(double dt)
|
|||||||
|
|
||||||
bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||||
{
|
{
|
||||||
//LOAD THE XML
|
//load the explosioneffect XML
|
||||||
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||||
|
|
||||||
EntityFileParser parser(deathEffect);
|
EntityFileParser parser(deathEffect);
|
||||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||||
|
|
||||||
//current components for player that we need
|
//components that we need from player
|
||||||
auto playerModelEW = e.Player.FirstChildByName("PlayerModel");
|
auto playerCamera = e.Player.FirstChildByName("Camera");
|
||||||
auto playerEntityModel = playerModelEW["Model"];
|
auto playerEntityModel = e.Player.FirstChildByName("PlayerModel")["Model"];
|
||||||
auto playerEntityTransform = playerModelEW["Transform"];
|
auto playerEntityAnimation = e.Player.FirstChildByName("PlayerModel")["Animation"];
|
||||||
|
|
||||||
//copy the data from player to new playermodel
|
//copy the data from player to explisioneffectmodel
|
||||||
playerEntityModel.Copy(deathEffectEW["Model"]);
|
playerEntityModel.Copy(deathEffectEW["Model"]);
|
||||||
playerEntityTransform.Copy(deathEffectEW["Transform"]);
|
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
||||||
|
//freeze the animation
|
||||||
|
deathEffectEW["Animation"]["Speed"] = 0.0;
|
||||||
|
|
||||||
//change the animation speed and make sure the explosioneffect spawns at the players position
|
//copy the models position,orientation
|
||||||
//http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/
|
deathEffectEW["Transform"]["Position"] = (glm::vec3)e.Player["Transform"]["Position"];
|
||||||
auto playerPosition = (glm::vec3)e.Player["Transform"]["Position"];
|
deathEffectEW["Transform"]["Orientation"] = (glm::vec3)e.Player["Transform"]["Orientation"];
|
||||||
deathEffectEW["Transform"]["Position"] = playerPosition;
|
//effect,camera is relative to playersPosition
|
||||||
deathEffectEW["ExplosionEffect"]["ExplosionOrigin"] = playerPosition;
|
deathEffectEW["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 0, 0);
|
||||||
|
|
||||||
//camera (with lifetime) slightly above the player and looking down at the player
|
//camera (with lifetime) behind the player
|
||||||
//camera will be positioned just above the player
|
|
||||||
glm::vec3 cameraPosition = glm::vec3(0, 10, 0);
|
|
||||||
auto cam = deathEffectEW.FirstChildByName("Camera");
|
auto cam = deathEffectEW.FirstChildByName("Camera");
|
||||||
cam["Transform"]["Position"] = cameraPosition;
|
cam["Transform"]["Position"] = glm::vec3(0, 2.5f, 1.8f);
|
||||||
|
cam["Transform"]["Orientation"] = glm::vec3(5.655f, 0, 0);
|
||||||
Events::SetCamera eSetCamera;
|
Events::SetCamera eSetCamera;
|
||||||
eSetCamera.CameraEntity = cam;
|
eSetCamera.CameraEntity = cam;
|
||||||
m_EventBroker->Publish(eSetCamera);
|
m_EventBroker->Publish(eSetCamera);
|
||||||
|
|
||||||
//on deathanim done -> del entity
|
//done -> del entity
|
||||||
m_World->DeleteEntity(e.Player.ID);
|
m_World->DeleteEntity(e.Player.ID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user