Movement animations

This commit is contained in:
viktorljung
2016-03-04 09:39:16 +01:00
parent 7ba0e4ea9d
commit c1f5cf65a7
3 changed files with 117 additions and 51 deletions
@@ -129,14 +129,23 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
if (val > 0) { if (val > 0) {
Events::AutoAnimationBlend aeb; Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1; aeb.Duration = 0.1;
if(m_Crouching) {
aeb.NodeName = "Walk";
} else {
aeb.NodeName = "Run"; aeb.NodeName = "Run";
}
aeb.RootNode = playerModel; aeb.RootNode = playerModel;
aeb.Start = true; aeb.Start = true;
m_EventBroker->Publish(aeb); m_EventBroker->Publish(aeb);
} else if (val < 0) { } else if (val < 0) {
Events::AutoAnimationBlend aeb; Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1; aeb.Duration = 0.1;
if (m_Crouching) {
aeb.NodeName = "Walk";
} else {
aeb.NodeName = "Run"; aeb.NodeName = "Run";
}
aeb.RootNode = playerModel; aeb.RootNode = playerModel;
aeb.Start = true; aeb.Start = true;
aeb.Reverse = true; aeb.Reverse = true;
+8 -8
View File
@@ -894,11 +894,11 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="Left"> <Entity name="Right">
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName>StrafeLeftF</AnimationName> <AnimationName>StrafeRightF</AnimationName>
<Time>0.25350140317161873</Time> <Time>0.27701693305173336</Time>
<Speed>1</Speed> <Speed>1</Speed>
<Play>true</Play> <Play>true</Play>
</c:Animation> </c:Animation>
@@ -906,11 +906,11 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="Right"> <Entity name="Left">
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName>StrafeRightF</AnimationName> <AnimationName>StrafeLeftF</AnimationName>
<Time>0.27701693305173336</Time> <Time>0.25350140317161873</Time>
<Speed>1</Speed> <Speed>1</Speed>
<Play>true</Play> <Play>true</Play>
</c:Animation> </c:Animation>
@@ -1022,7 +1022,7 @@
<c:Animation> <c:Animation>
<AnimationName>DashLeftF</AnimationName> <AnimationName>DashLeftF</AnimationName>
<Time>1</Time> <Time>1</Time>
<Speed>3</Speed> <Speed>2</Speed>
<Loop>false</Loop> <Loop>false</Loop>
</c:Animation> </c:Animation>
<c:Transform/> <c:Transform/>
@@ -1034,7 +1034,7 @@
<c:Animation> <c:Animation>
<AnimationName>DashRightF</AnimationName> <AnimationName>DashRightF</AnimationName>
<Time>1</Time> <Time>1</Time>
<Speed>3</Speed> <Speed>2</Speed>
<Loop>false</Loop> <Loop>false</Loop>
</c:Animation> </c:Animation>
<c:Transform/> <c:Transform/>
+83 -26
View File
@@ -343,34 +343,23 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
EntityWrapper dashEffect = entityFile->MergeInto(m_World); EntityWrapper dashEffect = entityFile->MergeInto(m_World);
EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
/* for (auto& kv : m_PlayerInputControllers) {
auto playerEntityModel = playerModel["Model"]; EntityWrapper player = kv.first;
auto& controller = kv.second;
if (!player.Valid()) {
if (player.HasComponent("Physics")) { continue;
glm::vec3 velocity = (glm::vec3)player["Physics"]["Velocity"];
glm::vec2 direction = glm::vec2(velocity.x, velocity.z);
std::string DashName = "";
if (glm::abs(direction.x) > glm::abs(direction.y)) {
if(glm::sign(direction.x) > 0) {
DashName = "DashRight";
} else {
DashName = "DashLeft";
}
} else {
if (glm::sign(direction.y) > 0) {
DashName = "DashForward";
} else {
DashName = "DashBackward";
}
} }
if (player.Valid()) {
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
if (glm::abs(controller->Movement().x) > glm::abs(controller->Movement().z)) {
if (controller->Movement().x > 0) {
{ {
Events::AutoAnimationBlend aeb; Events::AutoAnimationBlend aeb;
aeb.Duration = 0.1; aeb.Duration = 0.3;
aeb.NodeName = DashName; aeb.NodeName = "DashRight";
aeb.RootNode = playerModel; aeb.RootNode = playerModel;
aeb.Restart = true; aeb.Restart = true;
aeb.Start = true; aeb.Start = true;
@@ -381,14 +370,82 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
aeb.Duration = 0.3; aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend"; aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = playerModel; aeb.RootNode = playerModel;
aeb.Delay = 0.3; aeb.Delay = -0.3;
aeb.Start = true; aeb.Start = true;
aeb.Restart = false; aeb.Restart = false;
aeb.AnimationEntity = playerModel.FirstChildByName(DashName); aeb.AnimationEntity = playerModel.FirstChildByName("DashForward");
m_EventBroker->Publish(aeb);
}
} else {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "DashLeft";
aeb.RootNode = playerModel;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = playerModel;
aeb.Delay = -0.3;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = playerModel.FirstChildByName("DashForward");
m_EventBroker->Publish(aeb); m_EventBroker->Publish(aeb);
} }
} }
*/ } else {
if (controller->Movement().z < 0) {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "DashForward";
aeb.RootNode = playerModel;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = playerModel;
aeb.Delay = -0.3;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = playerModel.FirstChildByName("DashForward");
m_EventBroker->Publish(aeb);
}
} else {
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "DashBackward";
aeb.RootNode = playerModel;
aeb.Restart = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
{
Events::AutoAnimationBlend aeb;
aeb.Duration = 0.3;
aeb.NodeName = "StandCrouchBlend";
aeb.RootNode = playerModel;
aeb.Delay = -0.3;
aeb.Start = true;
aeb.Restart = false;
aeb.AnimationEntity = playerModel.FirstChildByName("DashForward");
m_EventBroker->Publish(aeb);
}
}
}
}
}
}
/* /*
auto playerEntityAnimation = playerModel["Animation"]; auto playerEntityAnimation = playerModel["Animation"];