Aim fixed for all weapons
This commit is contained in:
@@ -82,17 +82,15 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
// Limit camera pitch so we don't break our necks
|
||||
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi<float>(), glm::half_pi<float>());
|
||||
|
||||
float pitch = cameraOrientation.x;
|
||||
double time = ((pitch + glm::half_pi<float>()) / glm::pi<float>());
|
||||
|
||||
// Set third person model aim pitch
|
||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||
if (playerModel.Valid()) {
|
||||
EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("Aim");
|
||||
if(aimPrimaryEntity.Valid()){
|
||||
if(aimPrimaryEntity.HasComponent("Animation")) {
|
||||
float pitch = cameraOrientation.x;
|
||||
double time = ((pitch + glm::half_pi<float>()) / glm::pi<float>());
|
||||
(double&)aimPrimaryEntity["Animation"]["Time"] = time;
|
||||
}
|
||||
}
|
||||
setAim(playerModel, "SidearmWeapon", time);
|
||||
setAim(playerModel, "AssaultWeapon", time);
|
||||
setAim(playerModel, "DefenderWeapon", time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +306,25 @@ void PlayerMovementSystem::updateVelocity(EntityWrapper player, double dt)
|
||||
position += velocity * (float)dt;
|
||||
}
|
||||
|
||||
|
||||
void PlayerMovementSystem::setAim(EntityWrapper root, std::string weaponNodeName, double time)
|
||||
{
|
||||
if (root.Valid()) {
|
||||
EntityWrapper blendTreeUpper = root.FirstChildByName("BlendTreeUpper");
|
||||
if (blendTreeUpper.Valid()) {
|
||||
EntityWrapper weapon = blendTreeUpper.FirstChildByName(weaponNodeName);
|
||||
if(weapon.Valid()) {
|
||||
EntityWrapper aim = weapon.FirstChildByName("Aim");
|
||||
if (aim.Valid()) {
|
||||
if (aim.HasComponent("Animation")) {
|
||||
(double&)aim["Animation"]["Time"] = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMovementSystem::playerStep(double dt)
|
||||
{
|
||||
if (!m_LocalPlayer.Valid()) {
|
||||
|
||||
Reference in New Issue
Block a user