更改模型结构,方便以后更改人物模型

This commit is contained in:
huyulong 2024-12-02 15:09:22 +08:00
parent 975d8aac61
commit e56213a52d
13 changed files with 470 additions and 579 deletions

View File

@ -10,9 +10,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 4133915569911699731} - component: {fileID: 4133915569911699731}
- component: {fileID: 8052069560183341929} - component: {fileID: 8052069560183341929}
- component: {fileID: 4527286627946239905}
- component: {fileID: 4527286627946239907}
- component: {fileID: 4527286627946239904}
- component: {fileID: 4527286627946239896} - component: {fileID: 4527286627946239896}
- component: {fileID: 4527286627946239897} - component: {fileID: 4527286627946239897}
- component: {fileID: 4527286627946239910} - component: {fileID: 4527286627946239910}
@ -66,49 +63,6 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0 m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0 m_WriteDefaultValuesOnDisable: 0
--- !u!54 &4527286627946239905
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
--- !u!136 &4527286627946239907
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.3
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 1, z: 0}
--- !u!65 &4527286627946239904
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.5, y: 1.5, z: 0.5}
m_Center: {x: 0, y: 1, z: 0}
--- !u!114 &4527286627946239896 --- !u!114 &4527286627946239896
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -116,7 +70,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eccdd1a2db5ba4848bcb2eea6ed8ddb8, type: 3} m_Script: {fileID: 11500000, guid: eccdd1a2db5ba4848bcb2eea6ed8ddb8, type: 3}
m_Name: m_Name:
@ -130,13 +84,13 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b0e8bb916545c834b8981bdf116ec889, type: 3} m_Script: {fileID: 11500000, guid: b0e8bb916545c834b8981bdf116ec889, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
relativePosition: {x: 0, y: 0, z: 0} relativePosition: {x: 0, y: 0, z: 0}
relativeRotation: {x: 180, y: 90, z: 0} relativeRotation: {x: 180, y: 225, z: -45}
pickUpRange: 2 pickUpRange: 2
--- !u!114 &4527286627946239910 --- !u!114 &4527286627946239910
MonoBehaviour: MonoBehaviour:
@ -145,7 +99,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 776645053b40a604db295f0167ee1a67, type: 3} m_Script: {fileID: 11500000, guid: 776645053b40a604db295f0167ee1a67, type: 3}
m_Name: m_Name:
@ -164,7 +118,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3} m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3}
m_Name: m_Name:
@ -180,7 +134,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f5ee0c437a82c154fbb3f7f2d268c19b, type: 3} m_Script: {fileID: 11500000, guid: f5ee0c437a82c154fbb3f7f2d268c19b, type: 3}
m_Name: m_Name:
@ -193,7 +147,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 340618fb82d9f7246a985879a59c7b4d, type: 3} m_Script: {fileID: 11500000, guid: 340618fb82d9f7246a985879a59c7b4d, type: 3}
m_Name: m_Name:
@ -214,12 +168,14 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea9eb82687dfa674e883273cd7c73386, type: 3} m_Script: {fileID: 11500000, guid: ea9eb82687dfa674e883273cd7c73386, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
ain: {fileID: 0}
characterState: 0 characterState: 0
PlayerCollider: {fileID: 0}
--- !u!114 &543450652475625313 --- !u!114 &543450652475625313
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -227,7 +183,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a03ec7aa563e32d4ea7ce35cdd3e6f2b, type: 3} m_Script: {fileID: 11500000, guid: a03ec7aa563e32d4ea7ce35cdd3e6f2b, type: 3}
m_Name: m_Name:
@ -241,7 +197,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313} m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c377cd4742c7966498dda3a5e984db05, type: 3} m_Script: {fileID: 11500000, guid: c377cd4742c7966498dda3a5e984db05, type: 3}
m_Name: m_Name:
@ -249,8 +205,9 @@ MonoBehaviour:
joystick: {fileID: 0} joystick: {fileID: 0}
cameraTransform: {fileID: 0} cameraTransform: {fileID: 0}
moveSpeed: 5 moveSpeed: 5
characterControl: {fileID: 0} characterControl: {fileID: 4527286627946239909}
mainCamera: {fileID: 0} mainCamera: {fileID: 0}
rb: {fileID: 0}
normalFOV: 60 normalFOV: 60
sprintFOV: 120 sprintFOV: 120
fovChangeSpeed: 2 fovChangeSpeed: 2

File diff suppressed because it is too large Load Diff

View File

@ -27,13 +27,16 @@ public enum CharacterSkill
public class CharacterAin : MonoBehaviour public class CharacterAin : MonoBehaviour
{ {
private Animator ain; [Header("动画")]
public Animator ain;
private float timer; private float timer;
private float RunSpeed; private float RunSpeed;
[HideInInspector]
public CharacterState characterState; public CharacterState characterState;
[Header("碰撞体")]
public Collider PlayerCollider;
//鯤소툭旒竟 //鯤소툭旒竟
private Vector3 colExtents; private Vector3 colExtents;
@ -58,8 +61,8 @@ public class CharacterAin : MonoBehaviour
void Init() void Init()
{ {
ain = transform.GetComponent<Animator>(); //ain = transform.GetComponent<Animator>();
colExtents = GetComponent<Collider>().bounds.extents; colExtents = PlayerCollider.bounds.extents;
characterState = CharacterState.idle; characterState = CharacterState.idle;
SetPlayerState(characterState); SetPlayerState(characterState);
} }

View File

@ -38,7 +38,7 @@ public class PlayerMovement_Jpystick : MonoBehaviour, IDragHandler
{ {
characterControl = GetComponent<CharacterControl>(); characterControl = GetComponent<CharacterControl>();
Characterain = GetComponent<CharacterAin>(); Characterain = GetComponent<CharacterAin>();
rb = GetComponent<Rigidbody>(); //rb = GetComponent<Rigidbody>();
Debug.Log("------------------"+rb); Debug.Log("------------------"+rb);
} }

View File

@ -15,7 +15,7 @@ public class Skill_Jump : MonoBehaviour
private bool isVaulting = false; // 标志角色是否正在翻越 private bool isVaulting = false; // 标志角色是否正在翻越
private Collider characterCollider; // 角色的碰撞体 private Collider characterCollider; // 角色的碰撞体
private Rigidbody characterRigidbody; // 角色的刚体 public Rigidbody characterRigidbody; // 角色的刚体
private void Start() private void Start()
{ {

View File

@ -7,7 +7,10 @@ public class Skill_Pick : MonoBehaviour
//private CharacterAin CharacterAin; //private CharacterAin CharacterAin;
//角色动画控制器用于获取角色具体身体Transform捡东西 //角色动画控制器用于获取角色具体身体Transform捡东西
private Animator CharacterAnimator; public Animator CharacterAnimator;
public Transform player;
private Transform rightHand, leftHand; private Transform rightHand, leftHand;
@ -20,10 +23,9 @@ public class Skill_Pick : MonoBehaviour
// 用于检测玩家附近物品的范围 // 用于检测玩家附近物品的范围
public float pickUpRange = 2.0f; public float pickUpRange = 2.0f;
// Start is called before the first frame update
void Start() void Start()
{ {
CharacterAnimator = transform.GetComponent<Animator>(); //CharacterAnimator = transform.GetComponent<Animator>();
if (CharacterAnimator != null) if (CharacterAnimator != null)
{ {
rightHand = CharacterAnimator.GetBoneTransform(HumanBodyBones.RightHand); rightHand = CharacterAnimator.GetBoneTransform(HumanBodyBones.RightHand);
@ -31,17 +33,16 @@ public class Skill_Pick : MonoBehaviour
} }
else else
{ {
Debug.LogError("ÕÒ²»µ½ Animator "); Debug.LogError(transform.name+"ÕÒ²»µ½ Animator ");
} }
} }
// 捡起 // 捡起
public GameObject Pick() public GameObject Pick()
{ {
// 获取玩家当前位置 // 获取玩家当前位置
Vector3 playerPosition = transform.position; Vector3 playerPosition = player.transform.position;
// 使用物理射线或重叠球检测来查找玩家附近的物品 // 使用物理射线或重叠球检测来查找玩家附近的物品
Collider[] itemsInRange = Physics.OverlapSphere(playerPosition, pickUpRange, LayerMask.GetMask("Default")); Collider[] itemsInRange = Physics.OverlapSphere(playerPosition, pickUpRange, LayerMask.GetMask("Default"));
@ -63,12 +64,17 @@ public class Skill_Pick : MonoBehaviour
item.transform.localPosition = relativePosition; // 假设玩家手中有一个默认的持物位置 item.transform.localPosition = relativePosition; // 假设玩家手中有一个默认的持物位置
item.transform.localRotation = Quaternion.Euler(relativeRotation); // 重置旋转 item.transform.localRotation = Quaternion.Euler(relativeRotation); // 重置旋转
Debug.Log("^^^^^^^^^^^^^^^^^^^^^^^^^");
// 更新当前持有的物品 // 更新当前持有的物品
return item; return item;
} }
} }
Debug.Log("############################");
return null; return null;
} }
// 丢弃物品 // 丢弃物品

View File

@ -73,5 +73,10 @@ public class Skill_watering : MonoBehaviour
transform.forward = directionToFire; transform.forward = directionToFire;
} }
} }
} }

View File

@ -13,20 +13,21 @@ public class UseSkill : MonoBehaviour
//private CharacterAin CharacterAin; //private CharacterAin CharacterAin;
// 玩家手中当前持有的物品 // 玩家手中当前持有的物品
[HideInInspector]
public GameObject currentItem = null; public GameObject currentItem = null;
private Skill_Pick skill_Pick; public Skill_Pick _skill_Pick;
private Skill_Jump skill_Jump; public Skill_Jump _skill_Jump;
private Skill_watering skill_Watering; public Skill_watering _skill_Watering;
//Fire fire = new Fire(); //Fire fire = new Fire();
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
skill_Pick = transform.GetComponent<Skill_Pick>(); _skill_Pick = transform.GetComponent<Skill_Pick>();
skill_Jump = transform.GetComponent<Skill_Jump>(); _skill_Jump = transform.GetComponent<Skill_Jump>();
skill_Watering = transform.GetComponent<Skill_watering>(); _skill_Watering = transform.GetComponent<Skill_watering>();
//Debug.LogError(_skill_Pick.Pick());
} }
// Update is called once per frame // Update is called once per frame
@ -43,11 +44,12 @@ public class UseSkill : MonoBehaviour
if (Input.GetKeyDown(KeyCode.F)) if (Input.GetKeyDown(KeyCode.F))
{ {
Debug.LogError("F"); Debug.LogError("F");
currentItem = skill_Pick.Pick(); //Debug.LogError(skill_Pick.Pick());
currentItem = _skill_Pick.Pick();
} }
if (Input.GetKeyDown(KeyCode.Q)) if (Input.GetKeyDown(KeyCode.Q))
{ {
currentItem = skill_Pick.Drop(currentItem); currentItem = _skill_Pick.Drop(currentItem);
} }
} }
@ -67,13 +69,13 @@ public class UseSkill : MonoBehaviour
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
skill_Watering.StartWatering(currentItem); _skill_Watering.StartWatering(currentItem);
} }
if (Input.GetMouseButtonUp(0)) if (Input.GetMouseButtonUp(0))
{ {
skill_Watering.StopWatering(currentItem); _skill_Watering.StopWatering(currentItem);
} }
} }

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System; using System;
using System.Threading.Tasks;
public class SkillCoolDownUI : MonoBehaviour public class SkillCoolDownUI : MonoBehaviour
{ {
public Image cooldownImage; // 拖动Image组件到这里 public Image cooldownImage; // 拖动Image组件到这里
@ -11,16 +13,18 @@ public class SkillCoolDownUI : MonoBehaviour
private Coroutine countdownCoroutine; private Coroutine countdownCoroutine;
public void StartCooldown(float cooldownTime) public async void StartCooldown(float cooldownTime)
{ {
if (countdownCoroutine != null) if (countdownCoroutine != null)
{ {
StopCoroutine(countdownCoroutine); StopCoroutine(countdownCoroutine);
} }
countdownCoroutine = StartCoroutine(CooldownRoutine(cooldownTime));
// 调用异步方法来启动冷却
await CooldownRoutine(cooldownTime);
} }
private IEnumerator CooldownRoutine(float cooldownTime) public async Task CooldownRoutine(float cooldownTime)
{ {
float elapsed = 0f; float elapsed = 0f;
cooldownImage.fillAmount = 1; // 设置为满 cooldownImage.fillAmount = 1; // 设置为满
@ -30,12 +34,15 @@ public class SkillCoolDownUI : MonoBehaviour
elapsed += Time.deltaTime; elapsed += Time.deltaTime;
cooldownImage.fillAmount = 1 - (elapsed / cooldownTime); cooldownImage.fillAmount = 1 - (elapsed / cooldownTime);
cooldowntext.text = ((1 - (elapsed / cooldownTime)) * 10).ToString("F1"); cooldowntext.text = ((1 - (elapsed / cooldownTime)) * 10).ToString("F1");
yield return null;
// 使用 Task.Delay 来代替协程的 yield return
await Task.Yield(); // 让出当前帧,等待下次更新
} }
HandleCooldownFinished(); HandleCooldownFinished();
} }
private void HandleCooldownFinished() private void HandleCooldownFinished()
{ {
cooldownImage.fillAmount = 0; // 重新设置为0 cooldownImage.fillAmount = 0; // 重新设置为0
@ -43,4 +50,8 @@ public class SkillCoolDownUI : MonoBehaviour
Destroy(gameObject); Destroy(gameObject);
} }
} }

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f4763ae0ee2aab246b910f494007d8ef
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NPCInitial : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4d7df52381f65246820b1890ad97509
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,12 +4,12 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class FireHydrant : MonoBehaviour public class FireHydrant : MonoBehaviour
{ {
private GameObject xfs; public GameObject xfs;
// Start is called before the first frame update // Start is called before the first frame update
void Awake() void Awake()
{ {
xfs = GameObject.Find("Canvas/xfs"); //xfs = GameObject.Find("Canvas/xfs");
} }