1
0

2 کامیت‌ها c88fa538ac ... 68dfa38045

نویسنده SHA1 پیام تاریخ
  DESKTOP-5BUCSUT\LSR 68dfa38045 Merge branch 'main' of http://139.155.244.27:822/LSR/gouhuo 1 سال پیش
  DESKTOP-5BUCSUT\LSR 9167450b44 镜头旋转算法 1 سال پیش

+ 8 - 8
SFGgouhuo/Assets/Bundles/Model/player1.prefab

@@ -12,8 +12,8 @@ GameObject:
   - component: {fileID: 963194227}
   - component: {fileID: 963194226}
   - component: {fileID: 963194230}
-  - component: {fileID: 3466004247539312364}
-  m_Layer: 6
+  - component: {fileID: 3330349992106698532}
+  m_Layer: 0
   m_Name: Main Camera
   m_TagString: MainCamera
   m_Icon: {fileID: 0}
@@ -118,8 +118,8 @@ MonoBehaviour:
   m_RequiresDepthTexture: 0
   m_RequiresColorTexture: 0
   m_Version: 2
---- !u!65 &3466004247539312364
-BoxCollider:
+--- !u!135 &3330349992106698532
+SphereCollider:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
@@ -127,9 +127,9 @@ BoxCollider:
   m_GameObject: {fileID: 963194225}
   m_Material: {fileID: 0}
   m_IsTrigger: 1
-  m_Enabled: 1
+  m_Enabled: 0
   serializedVersion: 2
-  m_Size: {x: 1, y: 1, z: 1}
+  m_Radius: 0.01
   m_Center: {x: 0, y: 0, z: 0}
 --- !u!1 &25442114404645679
 GameObject:
@@ -4662,7 +4662,7 @@ MonoBehaviour:
   FallTimeout: 0.15
   groundLayers:
     serializedVersion: 2
-    m_Bits: 262144
+    m_Bits: 262273
   groundedOffset: -0.14
   groundedRadius: 0.28
   grounded: 1
@@ -4957,7 +4957,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 9195337467653545647}
-  m_Layer: 6
+  m_Layer: 0
   m_Name: CamRoot
   m_TagString: Untagged
   m_Icon: {fileID: 0}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 146 - 107
SFGgouhuo/Assets/Bundles/Scenes/MainScene.unity


+ 21 - 21
SFGgouhuo/Assets/GameResources/Player/PlayerArmature.prefab

@@ -152,7 +152,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427900362077118}
-  m_LocalRotation: {x: 0.60033333, y: 0.052875843, z: 0.0077310964, w: 0.7979626}
+  m_LocalRotation: {x: 0.60290444, y: 0.052759077, z: 0.0073525715, w: 0.79603314}
   m_LocalPosition: {x: 0.000004911422, y: 0.3789641, z: 0.0000036811825}
   m_LocalScale: {x: 0.9999998, y: 1.0000001, z: 0.99999994}
   m_Children:
@@ -463,7 +463,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427900711909222}
-  m_LocalRotation: {x: -0.0030739438, y: 0.1095994, z: -0.7832783, w: 0.6119262}
+  m_LocalRotation: {x: -0.0030739475, y: 0.1095994, z: -0.7832783, w: 0.61192614}
   m_LocalPosition: {x: 0.048186224, y: 0.14500271, z: 0.00531524}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
@@ -494,8 +494,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427900721381661}
-  m_LocalRotation: {x: -0.0008307574, y: 0.098624244, z: 0.9944541, w: 0.036520667}
-  m_LocalPosition: {x: -0.068759926, y: -0.042310603, z: 0.022965217}
+  m_LocalRotation: {x: -0.00048661564, y: 0.10285426, z: 0.99399906, w: 0.03723897}
+  m_LocalPosition: {x: -0.06875992, y: -0.04230612, z: 0.022968212}
   m_LocalScale: {x: 0.99999994, y: 1, z: 1.0000001}
   m_Children:
   - {fileID: 8762427901331142558}
@@ -526,8 +526,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427900724448093}
-  m_LocalRotation: {x: 0.00017015141, y: 0.098680675, z: 0.9944478, w: -0.036547717}
-  m_LocalPosition: {x: 0.06875991, y: -0.042310625, z: 0.02296522}
+  m_LocalRotation: {x: -0.00017943038, y: 0.1028298, z: 0.99400127, w: -0.037249807}
+  m_LocalPosition: {x: 0.06875992, y: -0.042306136, z: 0.022968212}
   m_LocalScale: {x: 1, y: 1.0000001, z: 1.0000001}
   m_Children:
   - {fileID: 8762427902295418897}
@@ -1014,7 +1014,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427900818529073}
-  m_LocalRotation: {x: 0.6003844, y: -0.05341728, z: -0.007362117, w: 0.79789156}
+  m_LocalRotation: {x: 0.60290676, y: -0.05331398, z: -0.0069855703, w: 0.7959977}
   m_LocalPosition: {x: -0.000004854202, y: 0.37896448, z: 0.0000036954875}
   m_LocalScale: {x: 0.99999976, y: 1, z: 0.9999999}
   m_Children:
@@ -1939,7 +1939,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427901331142559}
-  m_LocalRotation: {x: -0.066387184, y: -0.0011570703, z: 0.010939851, w: 0.9977333}
+  m_LocalRotation: {x: -0.07381697, y: -0.0011564025, z: 0.012160796, w: 0.99719703}
   m_LocalPosition: {x: -0.000014133454, y: 0.28059646, z: -0.0000091815}
   m_LocalScale: {x: 0.99999994, y: 0.9999998, z: 1.0000001}
   m_Children:
@@ -3062,8 +3062,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427901536452329}
-  m_LocalRotation: {x: -0.0853823, y: -0.000000020343814, z: -0.00000011514561, w: 0.9963483}
-  m_LocalPosition: {x: 0.000000016845178, y: 0.06558513, z: 0.000028406736}
+  m_LocalRotation: {x: -0.0853823, y: -0.00000002052062, z: -0.00000009343702, w: 0.9963483}
+  m_LocalPosition: {x: 0.000000011461312, y: 0.06558513, z: 0.000028406736}
   m_LocalScale: {x: 1, y: 1.0000001, z: 1.0000001}
   m_Children:
   - {fileID: 8762427900504199576}
@@ -3247,7 +3247,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427901671856371}
-  m_LocalRotation: {x: 0.0054027783, y: -0.007987421, z: 0.0059391507, w: 0.9999359}
+  m_LocalRotation: {x: 0.0054025473, y: -0.007987902, z: 0.005940475, w: 0.9999359}
   m_LocalPosition: {x: -0.000016029475, y: 0.18602979, z: -0.000017094611}
   m_LocalScale: {x: 1.0000001, y: 1.0000001, z: 1.0000002}
   m_Children:
@@ -3705,7 +3705,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427901885600985}
-  m_LocalRotation: {x: 0.005426292, y: 0.007986228, z: -0.0059554907, w: 0.9999357}
+  m_LocalRotation: {x: 0.0054264693, y: 0.0079863, z: -0.0059533035, w: 0.99993575}
   m_LocalPosition: {x: 0.000016171934, y: 0.18602999, z: -0.000017125609}
   m_LocalScale: {x: 1.0000001, y: 0.99999994, z: 1.0000001}
   m_Children:
@@ -3976,8 +3976,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427901997230135}
-  m_LocalRotation: {x: 0.06413489, y: 0.011690767, z: 0.118156016, w: 0.9908527}
-  m_LocalPosition: {x: -0.000009173527, y: 0.08570075, z: -0.0000024144538}
+  m_LocalRotation: {x: 0.06413496, y: 0.011691043, z: 0.11815488, w: 0.9908529}
+  m_LocalPosition: {x: -0.00000917539, y: 0.085700735, z: -0.0000024144538}
   m_LocalScale: {x: 0.99999994, y: 0.9999998, z: 1}
   m_Children:
   - {fileID: 8762427901671856370}
@@ -4069,8 +4069,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427902022659837}
-  m_LocalRotation: {x: 0.06434865, y: -0.009912908, z: -0.118032485, w: 0.99087304}
-  m_LocalPosition: {x: 0.000009411946, y: 0.08570075, z: -0.0000024221374}
+  m_LocalRotation: {x: 0.064348534, y: -0.0099128485, z: -0.1180346, w: 0.99087286}
+  m_LocalPosition: {x: 0.000009411946, y: 0.08570075, z: -0.0000024233016}
   m_LocalScale: {x: 1.0000002, y: 1.0000001, z: 1.0000002}
   m_Children:
   - {fileID: 8762427901885600984}
@@ -4226,7 +4226,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427902163220829}
-  m_LocalRotation: {x: -0.0030744434, y: -0.10959875, z: 0.7832789, w: 0.61192566}
+  m_LocalRotation: {x: -0.0030744416, y: -0.10959874, z: 0.7832789, w: 0.61192566}
   m_LocalPosition: {x: -0.048186224, y: 0.14500263, z: 0.0053152055}
   m_LocalScale: {x: 1, y: 0.99999994, z: 0.99999994}
   m_Children:
@@ -4319,8 +4319,8 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427902218368406}
-  m_LocalRotation: {x: 0.69834155, y: 2.8975575e-10, z: -0.000000017116406, w: 0.7157648}
-  m_LocalPosition: {x: 0, y: 0.0000076293945, z: -57.694782}
+  m_LocalRotation: {x: 0.69834155, y: 0.000000015651347, z: -0.000000032456374, w: 0.7157648}
+  m_LocalPosition: {x: 0, y: 0.0000076293945, z: -64.362114}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
   - {fileID: 8762427901970835926}
@@ -4412,7 +4412,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427902295418926}
-  m_LocalRotation: {x: -0.06651258, y: 0.0011558809, z: -0.01096095, w: 0.9977248}
+  m_LocalRotation: {x: -0.073800616, y: 0.0011556542, z: -0.012158829, w: 0.9971982}
   m_LocalPosition: {x: 0.000014123917, y: 0.28059638, z: -0.000009194316}
   m_LocalScale: {x: 1, y: 0.9999998, z: 1.0000001}
   m_Children:
@@ -4445,7 +4445,7 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 8762427902300486212}
-  m_LocalRotation: {x: 0.045167997, y: -1.6661667e-13, z: 0.0000001489354, w: 0.99897945}
+  m_LocalRotation: {x: 0.045167997, y: -1.6786567e-13, z: 0.00000014893538, w: 0.99897945}
   m_LocalPosition: {x: 2.025893e-15, y: 0.058465876, z: 0.011619233}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:

+ 109 - 39
SFGgouhuo/Assets/Scripts/MoveController.cs

@@ -1,5 +1,7 @@
+using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.EventSystems;
+using UnityEngine.InputSystem.HID;
 using static UnityEditor.ShaderGraph.Internal.KeywordDependentCollection;
 
 public class MoveController : MonoBehaviour
@@ -16,9 +18,9 @@ public class MoveController : MonoBehaviour
     private float angleY;
     private float jumpInterval = 0.5f;
     private float jumpTime = 0.5f;
+    private float oriDistance;
     private bool isGrounded = false;
     private bool hasLand = false;
-    private bool isBlock = false;
 
     private AnimatorController controller;
     private Transform head;
@@ -27,8 +29,6 @@ public class MoveController : MonoBehaviour
     private Vector3 gravityMove;
     private Vector3 lastMove;
     private Vector3 camInitPos;
-    private RaycastHit hit;
-    private Vector3 colliderDir;
 
     public enum PlayerState
     {
@@ -52,6 +52,7 @@ public class MoveController : MonoBehaviour
         head = transform.Find("Head");
         m_camera = camRoot.transform.Find("Main Camera");
         camInitPos = m_camera.localPosition;
+        oriDistance = Vector3.Distance(head.position, m_camera.position-m_camera.forward*2);
     }
 
     // Update is called once per frame
@@ -73,7 +74,7 @@ public class MoveController : MonoBehaviour
         }
         // ����Ƿ��ڵ�����
         //isGrounded = IsGrounded();
-        isGrounded = IsGrounded();
+        isGrounded =character.isGrounded|| IsGrounded();
         if (isGrounded && state == PlayerState.JumpDown)
         {
             verticalVelocity = 0;
@@ -124,7 +125,6 @@ public class MoveController : MonoBehaviour
 
         // �ƶ�����
         Move();
-        CameraLimitation();
         UpdateControlRotation();
     }
 
@@ -141,7 +141,7 @@ public class MoveController : MonoBehaviour
         // ���ݴ�ֱ�ٶ��ƶ�����
         if (verticalVelocity < 0.1f && verticalVelocity > -0.1f && state == PlayerState.JumpUp)
         {
-            Debug.Log("*************");
+            //Debug.Log("*************");
             state = PlayerState.JumpDown;
         }
 
@@ -151,6 +151,8 @@ public class MoveController : MonoBehaviour
 
     void Move()
     {
+        CameraLimitation();
+
         if (playerInput.MoveInput != Vector2.zero)
         {
             Vector3 dir = Vector3.zero;
@@ -312,67 +314,135 @@ public class MoveController : MonoBehaviour
         float sign = Mathf.Sign(Vector3.Dot(Vector3.Cross(m_camera.forward, Vector3.up), Vector3.up));
         float finalAngle = sign * angleDeg;
         //float moveDistance = Mathf.Sin(Mathf.Deg2Rad * Mathf.Clamp(finalAngle, 0f, 10)) * 2;
-        float z, obsDistance=0,camDistance=0;
+        float z, obsDistance = 0, camDistance = 0;
         //Debug.Log(finalAngle);
 
-        //���߼�����
-        //Ray ray = new Ray(head.position, m_camera.position - head.position);
-        //RaycastHit temphit;
-        //if (Physics.Raycast(ray, out temphit, 10f))
+        //射线检测是否有障碍物
+        Ray ray = new Ray(head.position, m_camera.position - head.position);
+
+        RaycastHit[] temphit;
+        RaycastHit hit;
+        var cos = Physics.Raycast(ray, out hit, oriDistance, ~(1 << 6|1<<18));
+        if (cos)
+        {
+
+            Debug.Log(hit.collider.name);
+            m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.5f);
+
+        }
+        else
+        {
+
+            m_camera.localPosition = Vector3.Lerp(m_camera.localPosition, camInitPos, 0.5f);
+
+        }
+
+
+
+
+        //RaycastHit[] temphit;
+        //var cos = Physics.RaycastAll(head.position, m_camera.position - head.position, oriDistance, ~(1 << 6));
+        //if (cos.Length>0)
         //{
-        //    if (temphit.collider.name != "Main Camera")
+        //    //Debug.Log(temphit.collider.name);
+        //    //m_camera.position = Vector3.Lerp(m_camera.position, temphit.point, 0.5f);
+        //    RaycastHit hit = cos[0];
+        //    float dis = 0;
+        //    for (int i = 1; i<cos.Length; i++)
         //    {
-        //        isBlock = true;
-        //        hit = temphit;
-        //        m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.1f);
+        //        if(dis< Vector3.Distance(cos[i].point, head.position))
+        //        {
+        //            dis = Vector3.Distance(cos[i].point, head.position);
+        //            hit = cos[i];
+
+        //        }
         //    }
-        //    else
+        //    if(!hit.collider.name.Contains("Main"))
         //    {
-        //        m_camera.localPosition = Vector3.Lerp(m_camera.localPosition, camInitPos, 0.5f);
+        //        Debug.Log(hit.collider.name);
+        //        m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.5f);
         //    }
 
-        //    Debug.Log(temphit.collider.name);
+
+        //    //if (temphit.collider.name != "Main Camera")
+        //    //{
+
+        //    //}
+        //    //else
+        //    //{
+        //    //    //如果射线没有打到任何collider,或者打到的不是墙体,则将相机和角色之间的距离还原
+        //    //    Vector3 p = (m_camera.position - head.position).normalized * oriDistance;
+        //    //    Vector3 newPoint = head.position + p;
+        //    //    m_camera.position = Vector3.Lerp(m_camera.position, newPoint, 0.5f);
+        //    //}
+        //}
+        //else
+        //{
+
+        //    m_camera.localPosition = Vector3.Lerp(m_camera.localPosition, camInitPos, 0.5f);
+
+        //}
+
+
+
+        //else
+        //{
+        //    //如果射线没有打到任何collider,或者打到的不是墙体,则将相机和角色之间的距离还原
+        //    Vector3 p = (m_camera.position - head.position).normalized * oriDistance;
+        //    Vector3 newPoint = head.position + p;
+        //    m_camera.localPosition = Vector3.Lerp(m_camera.position, new Vector3(0,1.48f,-5), 0.5f);
+        //}
+        //  
 
         //}
 
         //if (isBlock)
         //{
-        //    ////������ת��ͷ����
-        //    //if (finalAngle > 1)
+        ////������ת��ͷ����
+        //if (finalAngle > 1)
+        //{
+        //    z = finalAngle * 0.1f;
+        //    camDistance = Vector3.Distance(camInitPos + new Vector3(0, 0, z),head.position);
+        //    Debug.DrawLine(temphit.point, head.position, Color.red);
+        //    Debug.DrawLine(camInitPos + new Vector3(0, 0, z), head.position, Color.blue);
+        //    Debug.Log(hit.collider.name+"))"+obsDistance + " // " + camDistance);
+        //    //if (obsDistance < camDistance && obsDistance > 0)
         //    //{
-        //    //    z = finalAngle * 0.1f;
-        //    //    camDistance = Vector3.Distance(camInitPos + new Vector3(0, 0, z),head.position);
-        //    //    Debug.DrawLine(temphit.point, head.position, Color.red);
-        //    //    Debug.DrawLine(camInitPos + new Vector3(0, 0, z), head.position, Color.blue);
-        //    //    Debug.Log(hit.collider.name+"))"+obsDistance + " // " + camDistance);
-        //    //    //if (obsDistance < camDistance && obsDistance > 0)
-        //    //    //{
-        //    //    //    m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.1f);
-        //    //    //}
-        //    //    //else
-        //    //    //{
-        //    //    //    m_camera.localPosition = camInitPos + new Vector3(0, 0, z);
-        //    //    //}
-
+        //    //    m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.1f);
         //    //}
         //    //else
+        //    //{
+        //    //    m_camera.localPosition = camInitPos + new Vector3(0, 0, z);
+        //    //}
+
+        //}
+        //else
         //    {
         //        m_camera.position = Vector3.Lerp(m_camera.position, hit.point, 0.5f);
         //    }
         //}
         //else
         //{
-        //������ת��ͷ����
+        //旋转
         if (finalAngle > 1)
         {
             z = finalAngle * 0.1f;
-            m_camera.localPosition = camInitPos + new Vector3(0, 0, z);
+            var pos = camInitPos + new Vector3(0, 0, z);
+            var dis1 =Vector3.Distance(head.position, pos);
+            var dis2 =Vector3.Distance(m_camera.position, head.position);
+            if(!cos)
+                m_camera.localPosition = camInitPos + new Vector3(0, 0, z);
         }
-        else
+
+
+        if (m_camera.localPosition.z > -0.4f)
         {
-            m_camera.localPosition = Vector3.Lerp(m_camera.localPosition, camInitPos, 0.5f);
+            m_camera.localPosition = new Vector3(m_camera.localPosition.x, m_camera.localPosition.y,-0.4f);
         }
+        //else
+        //{
+        //    m_camera.localPosition = Vector3.Lerp(m_camera.localPosition, camInitPos, 0.5f);
+        //}
         //}
     }
-
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است