Browse Source

39_CrowdNavigation: animation sync

1vanK 9 years ago
parent
commit
bba9766c66

+ 3 - 3
Source/Samples/39_CrowdNavigation/CrowdNavigation.cpp

@@ -269,7 +269,7 @@ void CrowdNavigation::SpawnJack(const Vector3& pos, Node* jackGroup)
     CrowdAgent* agent = jackNode->CreateComponent<CrowdAgent>();
     CrowdAgent* agent = jackNode->CreateComponent<CrowdAgent>();
     agent->SetHeight(2.0f);
     agent->SetHeight(2.0f);
     agent->SetMaxSpeed(3.0f);
     agent->SetMaxSpeed(3.0f);
-    agent->SetMaxAccel(3.0f);
+    agent->SetMaxAccel(5.0f);
 }
 }
 
 
 void CrowdNavigation::CreateMushroom(const Vector3& pos)
 void CrowdNavigation::CreateMushroom(const Vector3& pos)
@@ -534,14 +534,14 @@ void CrowdNavigation::HandleCrowdAgentReposition(StringHash eventType, VariantMa
             // Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             // Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             node->SetRotation(node->GetRotation().Slerp(Quaternion(Vector3::FORWARD, velocity), 10.0f * timeStep * speedRatio));
             node->SetRotation(node->GetRotation().Slerp(Quaternion(Vector3::FORWARD, velocity), 10.0f * timeStep * speedRatio));
             // Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
             // Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
-            animCtrl->SetSpeed(WALKING_ANI, speedRatio);
+            animCtrl->SetSpeed(WALKING_ANI, speedRatio * 1.5f);
         }
         }
         else
         else
             animCtrl->Play(WALKING_ANI, 0, true, 0.1f);
             animCtrl->Play(WALKING_ANI, 0, true, 0.1f);
 
 
         // If speed is too low then stop the animation
         // If speed is too low then stop the animation
         if (speed < agent->GetRadius())
         if (speed < agent->GetRadius())
-            animCtrl->Stop(WALKING_ANI, 0.8f);
+            animCtrl->Stop(WALKING_ANI, 0.5f);
     }
     }
 }
 }
 
 

+ 3 - 3
bin/Data/LuaScripts/39_CrowdNavigation.lua

@@ -206,7 +206,7 @@ function SpawnJack(pos, jackGroup)
     local agent = jackNode:CreateComponent("CrowdAgent")
     local agent = jackNode:CreateComponent("CrowdAgent")
     agent.height = 2.0
     agent.height = 2.0
     agent.maxSpeed = 3.0
     agent.maxSpeed = 3.0
-    agent.maxAccel = 3.0
+    agent.maxAccel = 5.0
 end
 end
 
 
 function CreateMushroom(pos)
 function CreateMushroom(pos)
@@ -433,14 +433,14 @@ function HandleCrowdAgentReposition(eventType, eventData)
             -- Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             -- Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             node.rotation = node.rotation:Slerp(Quaternion(Vector3.FORWARD, velocity), 10.0 * timeStep * speedRatio)
             node.rotation = node.rotation:Slerp(Quaternion(Vector3.FORWARD, velocity), 10.0 * timeStep * speedRatio)
             -- Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
             -- Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
-            animCtrl:SetSpeed(WALKING_ANI, speedRatio)
+            animCtrl:SetSpeed(WALKING_ANI, speedRatio * 1.5)
         else
         else
             animCtrl:Play(WALKING_ANI, 0, true, 0.1)
             animCtrl:Play(WALKING_ANI, 0, true, 0.1)
         end
         end
 
 
         -- If speed is too low then stop the animation
         -- If speed is too low then stop the animation
         if speed < agent.radius then
         if speed < agent.radius then
-            animCtrl:Stop(WALKING_ANI, 0.8)
+            animCtrl:Stop(WALKING_ANI, 0.5)
         end
         end
     end
     end
 end
 end

+ 3 - 3
bin/Data/Scripts/39_CrowdNavigation.as

@@ -230,7 +230,7 @@ void SpawnJack(const Vector3& pos, Node@ jackGroup)
     CrowdAgent@ agent = jackNode.CreateComponent("CrowdAgent");
     CrowdAgent@ agent = jackNode.CreateComponent("CrowdAgent");
     agent.height = 2.0f;
     agent.height = 2.0f;
     agent.maxSpeed = 3.0f;
     agent.maxSpeed = 3.0f;
-    agent.maxAccel = 3.0f;
+    agent.maxAccel = 5.0f;
 }
 }
 
 
 void CreateBoxOffMeshConnections(DynamicNavigationMesh@ navMesh, Node@ boxGroup)
 void CreateBoxOffMeshConnections(DynamicNavigationMesh@ navMesh, Node@ boxGroup)
@@ -485,14 +485,14 @@ void HandleCrowdAgentReposition(StringHash eventType, VariantMap& eventData)
             // Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             // Face the direction of its velocity but moderate the turning speed based on the speed ratio and timeStep
             node.rotation = node.rotation.Slerp(Quaternion(FORWARD, velocity), 10.f * timeStep * speedRatio);
             node.rotation = node.rotation.Slerp(Quaternion(FORWARD, velocity), 10.f * timeStep * speedRatio);
             // Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
             // Throttle the animation speed based on agent speed ratio (ratio = 1 is full throttle)
-            animCtrl.SetSpeed(WALKING_ANI, speedRatio);
+            animCtrl.SetSpeed(WALKING_ANI, speedRatio * 1.5f);
         }
         }
         else
         else
             animCtrl.Play(WALKING_ANI, 0, true, 0.1f);
             animCtrl.Play(WALKING_ANI, 0, true, 0.1f);
 
 
         // If speed is too low then stop the animation
         // If speed is too low then stop the animation
         if (speed < agent.radius)
         if (speed < agent.radius)
-            animCtrl.Stop(WALKING_ANI, 0.8f);
+            animCtrl.Stop(WALKING_ANI, 0.5f);
     }
     }
 }
 }