Browse Source

6/5更新

2025/6/5	修正互动动画播放倒计时问题
修改睡眠状态下,两个狗如果距离过近,会出现睡眠状态下进入random移动状态。
Jees 2 days ago
parent
commit
807b760fcd

+ 12 - 9
Assets/Resources/Dog/AnimatorController/shibaInu/HomeDogInteractController.controller

@@ -233,7 +233,7 @@ AnimatorStateMachine:
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_Name: Death
+  m_Name: DeathSub
   m_ChildStates:
   - serializedVersion: 1
     m_State: {fileID: -961187681864823423}
@@ -503,7 +503,7 @@ AnimatorState:
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_Name: Start
+  m_Name: Death
   m_Speed: 1
   m_CycleOffset: 0
   m_Transitions:
@@ -631,6 +631,12 @@ AnimatorController:
     m_DefaultInt: 0
     m_DefaultBool: 0
     m_Controller: {fileID: 9100000}
+  - m_Name: Touch_status
+    m_Type: 4
+    m_DefaultFloat: 0
+    m_DefaultInt: 0
+    m_DefaultBool: 0
+    m_Controller: {fileID: 9100000}
   - m_Name: activeIndex
     m_Type: 3
     m_DefaultFloat: 0
@@ -715,12 +721,6 @@ AnimatorController:
     m_DefaultInt: 0
     m_DefaultBool: 0
     m_Controller: {fileID: 9100000}
-  - m_Name: Touch_status
-    m_Type: 4
-    m_DefaultFloat: 0
-    m_DefaultInt: 0
-    m_DefaultBool: 0
-    m_Controller: {fileID: 9100000}
   m_AnimatorLayers:
   - serializedVersion: 5
     m_Name: Base Layer
@@ -926,7 +926,10 @@ AnimatorStateTransition:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_Name: 
-  m_Conditions: []
+  m_Conditions:
+  - m_ConditionMode: 2
+    m_ConditionEvent: Death_status
+    m_EventTreshold: 0
   m_DstStateMachine: {fileID: 0}
   m_DstState: {fileID: 533779715773965248}
   m_Solo: 0

+ 1 - 1
Assets/Resources/VoiceAndManu/MenuController.cs

@@ -257,7 +257,7 @@ public class MenuController : MonoBehaviour
         GameData.focusDog = index;
         //Debug.Log("e delta time=" + e.);
         float deltaTime = Time.unscaledTime - dogNamePressStartTime;
-        Debug.Log("delta time is:" + deltaTime.ToString());
+        // Debug.Log("delta time is:" + deltaTime.ToString());
         if (deltaTime < longPressTime)
         {
             // 短按效果,切换狗的名字

+ 1 - 1
Assets/Resources/VoiceAndManu/VoiceController.cs

@@ -125,10 +125,10 @@ public class VoiceController : MonoBehaviour
         // TODO 以后根据音频识别返回值修改狗的行动
         foreach (var dog in HomeController.dogsInScene)
         {
-            dog.animator.SetBool("isListening", false);
             // 如果在交互模式,就刷新最后交互时间
             if (dog.dogState == DogState.INTERACT)
             {
+                dog.animator.SetBool("Listen_status", false);
                 dog.interactLastUpdate = DateTime.Now;
             }
         }

+ 5 - 1
Assets/Scripts/Home/DogCollisionController.cs

@@ -38,7 +38,11 @@ public class DogCollisionController : MonoBehaviour
 
             foreach (var dog in HomeController.dogsInScene)
             {
-                if (dog.gameObject == thisDog)
+                if (dog.gameObject == thisDog && dog.dogState != DogState.SLEEP)
+                {
+                    // 如果狗正在睡觉,则不处理碰撞
+                    // 只处理非睡觉状态下的碰撞
+                    Debug.Log("dog move to location" + moveToLocation);
                 {
                     dog.moveToLocation = moveToLocation;
                     dog.RandomMove();

+ 16 - 1
Assets/Scripts/Home/HomeController.cs

@@ -563,6 +563,8 @@ public class HomeController : MonoBehaviour
             form.AddField("user_id", UserProperty.userId);
 
             StartCoroutine(WebController.PostRequest(url, form, filePath, callback: VoiceCommandCallback));
+            // 打印时间
+            Debug.Log("Voice command training request at " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         }
         else if (sceneMode == SceneMode.TRAINING)
         {
@@ -585,6 +587,8 @@ public class HomeController : MonoBehaviour
     // 语音呼唤上传回调函数
     void VoiceCommandCallback(string json)
     {
+        // 打印返回时间
+        Debug.Log("Voice command callback at " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         if (sceneMode == SceneMode.INACTIVE)
         {
             Debug.Log("Voice command callback");
@@ -633,9 +637,20 @@ public class HomeController : MonoBehaviour
                     }
                     //animator.SetTrigger(animationTrigger);
                     animator.Play(animationTrigger);
-                    animator.SetBool(animationBool, true);
+                    string[] noStatusCommand = { "turnL", "turnR" };
+                    if (Array.IndexOf(noStatusCommand, animationTrigger) < 0)
+                    {
+                        animator.SetBool(animationBool, true);
+                        Debug.Log(animationBool+"status is"+animator.GetBool(animationBool));
+                    }
+                    else
+                    {
+                        // turnL 和 turnR 动画不需要设置状态
+                    }
+                    // animator.SetBool(animationBool, true);
 
                     // 交互动画执行一段时间后停止
+                    dogsInScene[GameData.focusDog].interactAnimationStartTime = DateTime.Now;
                     StartCoroutine(dogsInScene[GameData.focusDog].InteractAnimationCountDown());
                 }
                 else