Run, Strafe and jump animations now playing
This commit is contained in:
@@ -12,8 +12,8 @@ template <typename EventContext>
|
|||||||
class EditorCameraInputController : public FirstPersonInputController<EventContext>
|
class EditorCameraInputController : public FirstPersonInputController<EventContext>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditorCameraInputController(EventBroker* eventBroker, unsigned int playerID)
|
EditorCameraInputController(EventBroker* eventBroker, unsigned int playerID, EntityWrapper playerEntity)
|
||||||
: FirstPersonInputController(eventBroker, playerID)
|
: FirstPersonInputController(eventBroker, playerID, playerEntity)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorCameraInputController::OnMousePress);
|
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorCameraInputController::OnMousePress);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorCameraInputController::OnMouseRelease);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorCameraInputController::OnMouseRelease);
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
#include "../Core/ELockMouse.h"
|
#include "../Core/ELockMouse.h"
|
||||||
#include "../Game/Events/EDashAbility.h"
|
#include "../Game/Events/EDashAbility.h"
|
||||||
#include "InputHandler.h"
|
#include "InputHandler.h"
|
||||||
|
#include "Rendering/EAutoAnimationBlend.h"
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
class FirstPersonInputController : public InputController<EventContext>
|
class FirstPersonInputController : public InputController<EventContext>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FirstPersonInputController(EventBroker* eventBroker, int playerID);
|
FirstPersonInputController(EventBroker* eventBroker, int playerID, EntityWrapper playerEntity);
|
||||||
|
|
||||||
virtual const glm::vec3 Movement() const { return m_Movement; }
|
virtual const glm::vec3 Movement() const { return m_Movement; }
|
||||||
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
||||||
@@ -34,6 +35,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const int m_PlayerID;
|
const int m_PlayerID;
|
||||||
|
EntityWrapper m_PlayerEntity;
|
||||||
|
|
||||||
bool m_MouseLocked = false;
|
bool m_MouseLocked = false;
|
||||||
glm::vec3 m_Rotation;
|
glm::vec3 m_Rotation;
|
||||||
glm::vec3 m_Movement;
|
glm::vec3 m_Movement;
|
||||||
@@ -65,9 +68,10 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
FirstPersonInputController<EventContext>::FirstPersonInputController(EventBroker* eventBroker, int playerID)
|
FirstPersonInputController<EventContext>::FirstPersonInputController(EventBroker* eventBroker, int playerID, EntityWrapper playerEntity)
|
||||||
: InputController(eventBroker)
|
: InputController(eventBroker)
|
||||||
, m_PlayerID(playerID)
|
, m_PlayerID(playerID)
|
||||||
|
, m_PlayerEntity(playerEntity)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &FirstPersonInputController::OnLockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &FirstPersonInputController::OnLockMouse);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &FirstPersonInputController::OnUnlockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &FirstPersonInputController::OnUnlockMouse);
|
||||||
@@ -118,13 +122,75 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
|
|||||||
if (e.Command == "Forward") {
|
if (e.Command == "Forward") {
|
||||||
float val = glm::clamp(e.Value, -1.f, 1.f);
|
float val = glm::clamp(e.Value, -1.f, 1.f);
|
||||||
m_Movement.z = -val;
|
m_Movement.z = -val;
|
||||||
|
|
||||||
|
if (m_PlayerEntity.Valid()) {
|
||||||
|
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
if (val > 0) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Run";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
} else if (val < 0) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Run";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Reverse = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (e.Command == "Right") {
|
if (e.Command == "Right") {
|
||||||
float val = glm::clamp(e.Value, -1.f, 1.f);
|
float val = glm::clamp(e.Value, -1.f, 1.f);
|
||||||
m_Movement.x = val;
|
m_Movement.x = val;
|
||||||
|
|
||||||
|
if (m_PlayerEntity.Valid()) {
|
||||||
|
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
|
||||||
|
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
if (val > 0) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Right";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
} else if (val < 0) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Left";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (glm::length2(m_Movement) > 0) {
|
if (glm::length2(m_Movement) > 0) {
|
||||||
m_Movement = glm::normalize(m_Movement);
|
m_Movement = glm::normalize(m_Movement);
|
||||||
|
} else {
|
||||||
|
if (m_PlayerEntity.Valid()) {
|
||||||
|
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
|
||||||
|
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Idle";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +225,32 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
|
|||||||
|
|
||||||
if (e.Command == "Crouch") {
|
if (e.Command == "Crouch") {
|
||||||
m_Crouching = e.Value > 0;
|
m_Crouching = e.Value > 0;
|
||||||
|
|
||||||
|
if (m_PlayerEntity.Valid()) {
|
||||||
|
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
if (e.Value == 0.f) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.3;
|
||||||
|
aeb.NodeName = "StandMovement";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = true;
|
||||||
|
aeb.SingleLevelBlend = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
} else if(e.Value == 1.0f) {
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.3;
|
||||||
|
aeb.NodeName = "CrouchMovement";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = true;
|
||||||
|
aeb.SingleLevelBlend = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.Command == "SpecialAbility") {
|
if (e.Command == "SpecialAbility") {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
double progress;
|
double progress;
|
||||||
bool Start;
|
bool Start;
|
||||||
bool SingleBlend;
|
bool SingleBlend;
|
||||||
|
double Weight;
|
||||||
std::unordered_map<EntityWrapper, double> StartWeights;
|
std::unordered_map<EntityWrapper, double> StartWeights;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ struct AutoAnimationBlend : Event
|
|||||||
bool Restart = false;
|
bool Restart = false;
|
||||||
bool SingleLevelBlend = false;
|
bool SingleLevelBlend = false;
|
||||||
|
|
||||||
|
double Weight = -1.0;
|
||||||
|
|
||||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -631,7 +631,6 @@
|
|||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Characters/Assault/AssaultBlue.mesh</Resource>
|
<Resource>Models/Characters/Assault/AssaultBlue.mesh</Resource>
|
||||||
<Color A="1" B="1" G="0.952941179" R="1"/>
|
<Color A="1" B="1" G="0.952941179" R="1"/>
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
@@ -719,12 +718,12 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:BlendOverride>
|
<c:BlendOverride>
|
||||||
<Master>ReloadSwitchBlend</Master>
|
<Master>ReloadSwitchBlend</Master>
|
||||||
<Slave>MovementBlend</Slave>
|
<Slave>FinalMovementBlend</Slave>
|
||||||
</c:BlendOverride>
|
</c:BlendOverride>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
<Entity name="MovementBlend">
|
<Entity name="FinalMovementBlend">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Blend>
|
<c:Blend>
|
||||||
<Pose1>StandCrouchBlend</Pose1>
|
<Pose1>StandCrouchBlend</Pose1>
|
||||||
@@ -987,7 +986,7 @@
|
|||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName>DashForwardF</AnimationName>
|
<AnimationName>DashForwardF</AnimationName>
|
||||||
<Time>1</Time>
|
<Time>1</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>2</Speed>
|
||||||
<Loop>false</Loop>
|
<Loop>false</Loop>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
@@ -999,7 +998,7 @@
|
|||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName>DashBackwardF</AnimationName>
|
<AnimationName>DashBackwardF</AnimationName>
|
||||||
<Time>1</Time>
|
<Time>1</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>2</Speed>
|
||||||
<Loop>false</Loop>
|
<Loop>false</Loop>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
@@ -1023,7 +1022,7 @@
|
|||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName>DashLeftF</AnimationName>
|
<AnimationName>DashLeftF</AnimationName>
|
||||||
<Time>1</Time>
|
<Time>1</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>3</Speed>
|
||||||
<Loop>false</Loop>
|
<Loop>false</Loop>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
@@ -1035,7 +1034,7 @@
|
|||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName>DashRightF</AnimationName>
|
<AnimationName>DashRightF</AnimationName>
|
||||||
<Time>1</Time>
|
<Time>1</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>3</Speed>
|
||||||
<Loop>false</Loop>
|
<Loop>false</Loop>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
m_ActualCamera = m_EditorCamera;
|
m_ActualCamera = m_EditorCamera;
|
||||||
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform");
|
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform");
|
||||||
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera");
|
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera");
|
||||||
m_EditorCameraInputController = new EditorCameraInputController<EditorSystem>(m_EventBroker, -1);
|
m_EditorCameraInputController = new EditorCameraInputController<EditorSystem>(m_EventBroker, -1, EntityWrapper::Invalid);
|
||||||
|
|
||||||
m_EditorGUI = new EditorGUI(m_World, m_EventBroker);
|
m_EditorGUI = new EditorGUI(m_World, m_EventBroker);
|
||||||
m_EditorGUI->SetEntitySelectedCallback(std::bind(&EditorSystem::OnEntitySelected, this, std::placeholders::_1));
|
m_EditorGUI->SetEntitySelectedCallback(std::bind(&EditorSystem::OnEntitySelected, this, std::placeholders::_1));
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
|
|||||||
abj.BlendInfo.progress = 0.0;
|
abj.BlendInfo.progress = 0.0;
|
||||||
abj.BlendInfo.Start = e.Start;
|
abj.BlendInfo.Start = e.Start;
|
||||||
abj.BlendInfo.SingleBlend = e.SingleLevelBlend;
|
abj.BlendInfo.SingleBlend = e.SingleLevelBlend;
|
||||||
|
abj.BlendInfo.Weight = e.Weight;
|
||||||
|
|
||||||
EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); // more than one
|
EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); // more than one
|
||||||
if (nodeEntity.Valid()) {
|
if (nodeEntity.Valid()) {
|
||||||
|
|||||||
@@ -207,6 +207,22 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo)
|
|||||||
{
|
{
|
||||||
std::vector<Node*> goalNodes = FindNodesByName(blendInfo.NodeName);
|
std::vector<Node*> goalNodes = FindNodesByName(blendInfo.NodeName);
|
||||||
|
|
||||||
|
if(blendInfo.Weight >= 0 && blendInfo.Weight <= 1.0) {
|
||||||
|
for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) {
|
||||||
|
EntityWrapper entity = (*it)->Entity;
|
||||||
|
|
||||||
|
if (entity.Valid()) {
|
||||||
|
if (entity.HasComponent("Blend")) {
|
||||||
|
(double&)entity["Blend"]["Weight"] = blendInfo.Weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return blendInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (blendInfo.Start) {
|
if (blendInfo.Start) {
|
||||||
for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) {
|
for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) {
|
||||||
EntityWrapper entity = (*it)->Entity;
|
EntityWrapper entity = (*it)->Entity;
|
||||||
|
|||||||
@@ -45,10 +45,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
//copy the data from player to explosioneffectmodel
|
//copy the data from player to explosioneffectmodel
|
||||||
playerEntityModel.Copy(deathEffectEW["Model"]);
|
playerEntityModel.Copy(deathEffectEW["Model"]);
|
||||||
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
||||||
//freeze the animation
|
|
||||||
deathEffectEW["Animation"]["Speed1"] = 0.0;
|
|
||||||
deathEffectEW["Animation"]["Speed2"] = 0.0;
|
|
||||||
deathEffectEW["Animation"]["Speed3"] = 0.0;
|
|
||||||
|
|
||||||
//copy the models position,orientation
|
//copy the models position,orientation
|
||||||
deathEffectEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
deathEffectEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
||||||
|
|||||||
@@ -42,11 +42,25 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi<float>(), glm::half_pi<float>());
|
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi<float>(), glm::half_pi<float>());
|
||||||
// Set third person model aim pitch
|
// Set third person model aim pitch
|
||||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
|
||||||
|
//Third-person aim
|
||||||
if (playerModel.Valid()) {
|
if (playerModel.Valid()) {
|
||||||
//ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"];
|
EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("AimPrimary");
|
||||||
//float pitch = cameraOrientation.x + 0.2f;
|
if(aimPrimaryEntity.Valid()){
|
||||||
//double time = (pitch + glm::half_pi<float>()) / glm::pi<float>();
|
if(aimPrimaryEntity.HasComponent("Animation")) {
|
||||||
//cAnimationOffset["Time"] = time;
|
float pitch = cameraOrientation.x + 0.2f;
|
||||||
|
double time = (pitch + glm::half_pi<float>()) / glm::pi<float>();
|
||||||
|
(double&)aimPrimaryEntity["Animation"]["Time"] = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EntityWrapper aimSecondaryEntity = playerModel.FirstChildByName("AimSecondary");
|
||||||
|
if (aimSecondaryEntity.Valid()) {
|
||||||
|
if (aimSecondaryEntity.HasComponent("Animation")) {
|
||||||
|
float pitch = cameraOrientation.x + 0.2f;
|
||||||
|
double time = (pitch + glm::half_pi<float>()) / glm::pi<float>();
|
||||||
|
(double&)aimSecondaryEntity["Animation"]["Time"] = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +154,64 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
if (isOnGround) {
|
if (isOnGround) {
|
||||||
(bool)cPhysics["IsOnGround"] = false;
|
(bool)cPhysics["IsOnGround"] = false;
|
||||||
velocity.y = player["Player"]["JumpSpeed"];
|
velocity.y = player["Player"]["JumpSpeed"];
|
||||||
|
|
||||||
|
|
||||||
|
if (player.Valid()) {
|
||||||
|
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.15;
|
||||||
|
aeb.NodeName = "Jump";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.25;
|
||||||
|
aeb.NodeName = "StandCrouchBlend";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = false;
|
||||||
|
aeb.AnimationEntity = playerModel.FirstChildByName("Jump");
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) {
|
} else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) {
|
||||||
//Enter here if player can double jump and is doing so.
|
//Enter here if player can double jump and is doing so.
|
||||||
(bool)cPhysics["IsOnGround"] = false;
|
(bool)cPhysics["IsOnGround"] = false;
|
||||||
velocity.y = player["DoubleJump"]["DoubleJumpSpeed"];
|
velocity.y = player["DoubleJump"]["DoubleJumpSpeed"];
|
||||||
|
|
||||||
|
if (player.Valid()) {
|
||||||
|
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
if (playerModel.Valid()) {
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.15;
|
||||||
|
aeb.NodeName = "Jump";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.25;
|
||||||
|
aeb.NodeName = "StandCrouchBlend";
|
||||||
|
aeb.RootNode = playerModel;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = false;
|
||||||
|
aeb.AnimationEntity = playerModel.FirstChildByName("Jump");
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If IsServer and network is off this will not work
|
// If IsServer and network is off this will not work
|
||||||
if (IsClient) {
|
if (IsClient) {
|
||||||
//put a hexagon at the players feet
|
//put a hexagon at the players feet
|
||||||
@@ -234,7 +302,7 @@ void PlayerMovementSystem::playerStep(double dt)
|
|||||||
bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||||
{
|
{
|
||||||
// When a player spawns, create an input controller for them
|
// When a player spawns, create an input controller for them
|
||||||
m_PlayerInputControllers[e.Player] = new FirstPersonInputController<PlayerMovementSystem>(m_EventBroker, e.PlayerID);
|
m_PlayerInputControllers[e.Player] = new FirstPersonInputController<PlayerMovementSystem>(m_EventBroker, e.PlayerID, e.Player);
|
||||||
if (e.PlayerID == -1) {
|
if (e.PlayerID == -1) {
|
||||||
// Keep track of the local player
|
// Keep track of the local player
|
||||||
m_LocalPlayer = e.Player;
|
m_LocalPlayer = e.Player;
|
||||||
@@ -267,18 +335,72 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
|||||||
bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
|
bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
|
||||||
{
|
{
|
||||||
EntityWrapper player(m_World, e.Player);
|
EntityWrapper player(m_World, e.Player);
|
||||||
if (!player.Valid() || !IsClient || player.ID == LocalPlayer.ID) {
|
if (!player.Valid() || !IsClient){// || player.ID == LocalPlayer.ID) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
||||||
EntityWrapper dashEffect = entityFile->MergeInto(m_World);
|
EntityWrapper dashEffect = entityFile->MergeInto(m_World);
|
||||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
|
||||||
|
/*
|
||||||
auto playerEntityModel = playerModel["Model"];
|
auto playerEntityModel = playerModel["Model"];
|
||||||
|
|
||||||
|
|
||||||
|
if (player.HasComponent("Physics")) {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = DashName;
|
||||||
|
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(DashName);
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
auto playerEntityAnimation = playerModel["Animation"];
|
auto playerEntityAnimation = playerModel["Animation"];
|
||||||
|
|
||||||
playerEntityModel.Copy(dashEffect["Model"]);
|
playerEntityModel.Copy(dashEffect["Model"]);
|
||||||
playerEntityAnimation.Copy(dashEffect["Animation"]);
|
playerEntityAnimation.Copy(dashEffect["Animation"]);
|
||||||
dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
|
dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
|
||||||
((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f;
|
((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi)
|
|||||||
// Play animation
|
// Play animation
|
||||||
EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent();
|
EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent();
|
||||||
if (modelEntity.Valid()) {
|
if (modelEntity.Valid()) {
|
||||||
EntityWrapper blendTree = modelEntity.FirstChildByName("AssaultWeaponBlendTree");
|
EntityWrapper blendTree = modelEntity.FirstChildByName("BlendTreeAssaultWeapon");
|
||||||
EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload");
|
EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload");
|
||||||
|
|
||||||
Events::AutoAnimationBlend eFireBlend;
|
Events::AutoAnimationBlend eFireBlend;
|
||||||
|
|||||||
Reference in New Issue
Block a user