Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b6facbfc authored by Daniel Dugas's avatar Daniel Dugas
Browse files

Animation transitions

parent 3922fd2f
No related branches found
No related tags found
No related merge requests found
...@@ -3147,10 +3147,10 @@ AnimatorStateMachine: ...@@ -3147,10 +3147,10 @@ AnimatorStateMachine:
m_Position: {x: -516, y: -504, z: 0} m_Position: {x: -516, y: -504, z: 0}
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 1102964328578706210} m_State: {fileID: 1102964328578706210}
m_Position: {x: -516, y: 96, z: 0} m_Position: {x: -510, y: 100, z: 0}
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 1102880699750407020} m_State: {fileID: 1102880699750407020}
m_Position: {x: -516, y: 336, z: 0} m_Position: {x: -520, y: 330, z: 0}
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 1102743880108120760} m_State: {fileID: 1102743880108120760}
m_Position: {x: -540, y: 0, z: 0} m_Position: {x: -540, y: 0, z: 0}
...@@ -4445,6 +4445,9 @@ AnimatorStateTransition: ...@@ -4445,6 +4445,9 @@ AnimatorStateTransition:
- m_ConditionMode: 6 - m_ConditionMode: 6
m_ConditionEvent: AnimationType m_ConditionEvent: AnimationType
m_EventTreshold: 2 m_EventTreshold: 2
- m_ConditionMode: 4
m_ConditionEvent: Speed
m_EventTreshold: 0.01
m_DstStateMachine: {fileID: 0} m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102964328578706210} m_DstState: {fileID: 1102964328578706210}
m_Solo: 0 m_Solo: 0
...@@ -4542,6 +4545,9 @@ AnimatorStateTransition: ...@@ -4542,6 +4545,9 @@ AnimatorStateTransition:
- m_ConditionMode: 6 - m_ConditionMode: 6
m_ConditionEvent: AnimationType m_ConditionEvent: AnimationType
m_EventTreshold: 1 m_EventTreshold: 1
- m_ConditionMode: 4
m_ConditionEvent: Speed
m_EventTreshold: 0.01
m_DstStateMachine: {fileID: 0} m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102880699750407020} m_DstState: {fileID: 1102880699750407020}
m_Solo: 0 m_Solo: 0
...@@ -4817,6 +4823,9 @@ AnimatorStateTransition: ...@@ -4817,6 +4823,9 @@ AnimatorStateTransition:
- m_ConditionMode: 6 - m_ConditionMode: 6
m_ConditionEvent: AnimationType m_ConditionEvent: AnimationType
m_EventTreshold: 3 m_EventTreshold: 3
- m_ConditionMode: 4
m_ConditionEvent: Speed
m_EventTreshold: 0.01
m_DstStateMachine: {fileID: 0} m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102743880108120760} m_DstState: {fileID: 1102743880108120760}
m_Solo: 0 m_Solo: 0
......
...@@ -15,9 +15,11 @@ public class AnimationController : MonoBehaviour ...@@ -15,9 +15,11 @@ public class AnimationController : MonoBehaviour
private uint agentID; private uint agentID;
private Vector3 _oldVelocity; private Vector3 _oldVelocity;
private Quaternion _oldRotation; private Quaternion _oldRotation;
private float _speed=0; private string _oldState = "Idle";
private float _timeIdle=0;
public string _defaultIdleAnimation = "Idle";
public bool IsIdle { get { return _speed<0.00001; } } public bool IsIdle { get { return _timeIdle > 1.0f; } }
// Use this for initialization // Use this for initialization
void Start() void Start()
...@@ -34,6 +36,7 @@ public class AnimationController : MonoBehaviour ...@@ -34,6 +36,7 @@ public class AnimationController : MonoBehaviour
_objectAnimator.speed = 0; _objectAnimator.speed = 0;
_objectAnimator.SetFloat("Speed", 0); _objectAnimator.SetFloat("Speed", 0);
_objectAnimator.SetFloat("AngularSpeed", 0); _objectAnimator.SetFloat("AngularSpeed", 0);
_objectAnimator.SetInteger("AnimationType", 1);
#if MIDDLEVR #if MIDDLEVR
_objectAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; _objectAnimator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
...@@ -84,7 +87,32 @@ public class AnimationController : MonoBehaviour ...@@ -84,7 +87,32 @@ public class AnimationController : MonoBehaviour
animationSpeed = position.magnitude / ToolsTime.DeltaTime / 1.4f; animationSpeed = position.magnitude / ToolsTime.DeltaTime / 1.4f;
_speed = animationSpeed; print("agent");
print(animationSpeed);
print(_timeIdle);
if (animationSpeed > 0.01f)
{
_timeIdle = 0.0f;
if (_oldState != "Walk")
{
_oldState = "Walk";
}
}
else
{
// wait before entering idle state
_timeIdle += ToolsTime.DeltaTime;
}
if (IsIdle)
{
animationSpeed = 0.0f;
if (_oldState != _defaultIdleAnimation)
{
print("Switching to Idle Animation");
_oldState = _defaultIdleAnimation;
_objectAnimator.Play(_defaultIdleAnimation);
}
}
_objectAnimator.SetFloat("Speed", animationSpeed); _objectAnimator.SetFloat("Speed", animationSpeed);
_objectAnimator.SetFloat("AngularSpeed", angularSpeed, 100f, ToolsTime.DeltaTime); _objectAnimator.SetFloat("AngularSpeed", angularSpeed, 100f, ToolsTime.DeltaTime);
_objectAnimator.SetBool("One-Eighty", false); _objectAnimator.SetBool("One-Eighty", false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment