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

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:
- component: {fileID: 4133915569911699731}
- component: {fileID: 8052069560183341929}
- component: {fileID: 4527286627946239905}
- component: {fileID: 4527286627946239907}
- component: {fileID: 4527286627946239904}
- component: {fileID: 4527286627946239896}
- component: {fileID: 4527286627946239897}
- component: {fileID: 4527286627946239910}
@ -66,49 +63,6 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 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
MonoBehaviour:
m_ObjectHideFlags: 0
@ -116,7 +70,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eccdd1a2db5ba4848bcb2eea6ed8ddb8, type: 3}
m_Name:
@ -130,13 +84,13 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b0e8bb916545c834b8981bdf116ec889, type: 3}
m_Name:
m_EditorClassIdentifier:
relativePosition: {x: 0, y: 0, z: 0}
relativeRotation: {x: 180, y: 90, z: 0}
relativeRotation: {x: 180, y: 225, z: -45}
pickUpRange: 2
--- !u!114 &4527286627946239910
MonoBehaviour:
@ -145,7 +99,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 776645053b40a604db295f0167ee1a67, type: 3}
m_Name:
@ -164,7 +118,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3}
m_Name:
@ -180,7 +134,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f5ee0c437a82c154fbb3f7f2d268c19b, type: 3}
m_Name:
@ -193,7 +147,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 340618fb82d9f7246a985879a59c7b4d, type: 3}
m_Name:
@ -214,12 +168,14 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea9eb82687dfa674e883273cd7c73386, type: 3}
m_Name:
m_EditorClassIdentifier:
ain: {fileID: 0}
characterState: 0
PlayerCollider: {fileID: 0}
--- !u!114 &543450652475625313
MonoBehaviour:
m_ObjectHideFlags: 0
@ -227,7 +183,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a03ec7aa563e32d4ea7ce35cdd3e6f2b, type: 3}
m_Name:
@ -241,7 +197,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3608877410834662313}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c377cd4742c7966498dda3a5e984db05, type: 3}
m_Name:
@ -249,8 +205,9 @@ MonoBehaviour:
joystick: {fileID: 0}
cameraTransform: {fileID: 0}
moveSpeed: 5
characterControl: {fileID: 0}
characterControl: {fileID: 4527286627946239909}
mainCamera: {fileID: 0}
rb: {fileID: 0}
normalFOV: 60
sprintFOV: 120
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
{
private Animator ain;
[Header("动画")]
public Animator ain;
private float timer;
private float RunSpeed;
public CharacterState characterState;
[HideInInspector]
public CharacterState characterState;
[Header("碰撞体")]
public Collider PlayerCollider;
//鯤소툭旒竟
private Vector3 colExtents;
@ -58,8 +61,8 @@ public class CharacterAin : MonoBehaviour
void Init()
{
ain = transform.GetComponent<Animator>();
colExtents = GetComponent<Collider>().bounds.extents;
//ain = transform.GetComponent<Animator>();
colExtents = PlayerCollider.bounds.extents;
characterState = CharacterState.idle;
SetPlayerState(characterState);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -11,22 +11,23 @@ using UnityEngine;
public class UseSkill : MonoBehaviour
{
//private CharacterAin CharacterAin;
// 玩家手中当前持有的物品
[HideInInspector]
public GameObject currentItem = null;
private Skill_Pick skill_Pick;
private Skill_Jump skill_Jump;
private Skill_watering skill_Watering;
public Skill_Pick _skill_Pick;
public Skill_Jump _skill_Jump;
public Skill_watering _skill_Watering;
//Fire fire = new Fire();
// Start is called before the first frame update
void Start()
{
skill_Pick = transform.GetComponent<Skill_Pick>();
skill_Jump = transform.GetComponent<Skill_Jump>();
skill_Watering = transform.GetComponent<Skill_watering>();
void Start()
{
_skill_Pick = transform.GetComponent<Skill_Pick>();
_skill_Jump = transform.GetComponent<Skill_Jump>();
_skill_Watering = transform.GetComponent<Skill_watering>();
//Debug.LogError(_skill_Pick.Pick());
}
// Update is called once per frame
@ -40,14 +41,15 @@ public class UseSkill : MonoBehaviour
//拾取
void Skill_Pick()
{
if (Input.GetKeyDown(KeyCode.F))
if (Input.GetKeyDown(KeyCode.F))
{
Debug.LogError("F");
currentItem = skill_Pick.Pick();
//Debug.LogError(skill_Pick.Pick());
currentItem = _skill_Pick.Pick();
}
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))
{
skill_Watering.StartWatering(currentItem);
_skill_Watering.StartWatering(currentItem);
}
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.UI;
using System;
using System.Threading.Tasks;
public class SkillCoolDownUI : MonoBehaviour
{
public Image cooldownImage; // 拖动Image组件到这里
@ -11,16 +13,18 @@ public class SkillCoolDownUI : MonoBehaviour
private Coroutine countdownCoroutine;
public void StartCooldown(float cooldownTime)
public async void StartCooldown(float cooldownTime)
{
if (countdownCoroutine != null)
{
StopCoroutine(countdownCoroutine);
}
countdownCoroutine = StartCoroutine(CooldownRoutine(cooldownTime));
// 调用异步方法来启动冷却
await CooldownRoutine(cooldownTime);
}
private IEnumerator CooldownRoutine(float cooldownTime)
public async Task CooldownRoutine(float cooldownTime)
{
float elapsed = 0f;
cooldownImage.fillAmount = 1; // 设置为满
@ -29,13 +33,16 @@ public class SkillCoolDownUI : MonoBehaviour
{
elapsed += Time.deltaTime;
cooldownImage.fillAmount = 1 - (elapsed / cooldownTime);
cooldowntext.text =((1 - (elapsed / cooldownTime))*10).ToString("F1");
yield return null;
cooldowntext.text = ((1 - (elapsed / cooldownTime)) * 10).ToString("F1");
// 使用 Task.Delay 来代替协程的 yield return
await Task.Yield(); // 让出当前帧,等待下次更新
}
HandleCooldownFinished();
}
private void HandleCooldownFinished()
{
cooldownImage.fillAmount = 0; // 重新设置为0
@ -43,4 +50,8 @@ public class SkillCoolDownUI : MonoBehaviour
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;
public class FireHydrant : MonoBehaviour
{
private GameObject xfs;
public GameObject xfs;
// Start is called before the first frame update
void Awake()
{
xfs = GameObject.Find("Canvas/xfs");
//xfs = GameObject.Find("Canvas/xfs");
}