feat(archer): 更新弓箭手攻击系统

- 修改箭矢材质颜色为橙色调,提升视觉效果
- 删除场景中预设的箭矢对象,改为运行时动态生成
- 配置弓箭手单位支持远程攻击类型,设置正确的项目引用
- 调整弓箭手碰撞体中心偏移,改善物理表现
- 新增箭矢发射位置标记点,用于准确控制投射物生成
- 禁用动画根运动防止旋转叠加,确保移动控制一致
- 添加场景辅助线显示箭矢发射位置,便于调试定位
- 优化弓箭模型动画循环参数,改进播放流畅度
```
This commit is contained in:
huadexuan committed 2026-08-27 17:44:37 +08:00
1 parent fe3877dedb
commit 840867963d
6 files changed
+81 -125

No files matched your search

@@ -15,7 +15,7 @@ GameObject:
- component: {fileID: 4651139754486402669} - component: {fileID: 4651139754486402669}
m_Layer: 0 m_Layer: 0
m_HasEditorInfo: 1 m_HasEditorInfo: 1
m_Name: ArrowProjectile_White m_Name: Arrow
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@@ -78,6 +78,6 @@ Material:
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 0.8238993, g: 0.57841074, b: 0.34458673, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
@@ -45,7 +45,7 @@ ModelImporter:
takeName: mixamo.com takeName: mixamo.com
internalID: -203655887218126122 internalID: -203655887218126122
firstFrame: 0 firstFrame: 0
lastFrame: 31 lastFrame: 31.099998
wrapMode: 0 wrapMode: 0
orientationOffsetY: 0 orientationOffsetY: 0
level: 0 level: 0
@@ -55,10 +55,10 @@ ModelImporter:
lockToRoot: 0 lockToRoot: 0
loopTime: 0 loopTime: 0
loopBlend: 0 loopBlend: 0
loopBlendOrientation: 0 loopBlendOrientation: 1
loopBlendPositionY: 0 loopBlendPositionY: 0
loopBlendPositionXZ: 0 loopBlendPositionXZ: 0
keepOriginalOrientation: 0 keepOriginalOrientation: 1
keepOriginalPositionY: 1 keepOriginalPositionY: 1
keepOriginalPositionXZ: 0 keepOriginalPositionXZ: 0
heightFromFeet: 0 heightFromFeet: 0
@@ -66,7 +66,7 @@ ModelImporter:
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: [] curves: []
events: events:
- time: 0.96719885 - time: 0.9866667
functionName: OnAttackEffect functionName: OnAttackEffect
data: data:
objectReferenceParameter: {instanceID: 0} objectReferenceParameter: {instanceID: 0}
+55 -119
View File
@@ -1637,106 +1637,6 @@ Transform:
- {fileID: 999094166} - {fileID: 999094166}
m_Father: {fileID: 452343421} m_Father: {fileID: 452343421}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1038486208
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2585195233482669526, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_Name
value: ArrowProjectile_White
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalScale.x
value: 0.01
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalScale.y
value: 0.3125
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalScale.z
value: 0.024999999
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalPosition.x
value: -2.272
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.373
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.166
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.5674013
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.81330854
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalRotation.y
value: -0.10561989
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.07368516
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 114.854004
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 34.772995
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 37.423004
objectReference: {fileID: 0}
- target: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: aae7b6830fce0ff43b065876eff5ef47, type: 3}
--- !u!1 &1038486209 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2585195233482669526, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
m_PrefabInstance: {fileID: 1038486208}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1038486210 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3274732106972909994, guid: aae7b6830fce0ff43b065876eff5ef47,
type: 3}
m_PrefabInstance: {fileID: 1038486208}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1063768498 --- !u!1 &1063768498
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1772,18 +1672,6 @@ Transform:
- {fileID: 1451120646} - {fileID: 1451120646}
m_Father: {fileID: 2019663515} m_Father: {fileID: 2019663515}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!134 &1111001695
PhysicMaterial:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
dynamicFriction: 0.6
staticFriction: 0.6
bounciness: 0
frictionCombine: 0
bounceCombine: 0
--- !u!1 &1156019067 --- !u!1 &1156019067
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1976,9 +1864,10 @@ MonoBehaviour:
attackRange: 5 attackRange: 5
attackPower: 10 attackPower: 10
attackDuration: 0 attackDuration: 0
attackType: 0 attackType: 2
projectilePrefab: {fileID: 1038486209} projectilePrefab: {fileID: 2585195233482669526, guid: aae7b6830fce0ff43b065876eff5ef47,
projectileSpawnPoint: {fileID: 1038486210} type: 3}
projectileSpawnPoint: {fileID: 1421129427}
projectileSpeed: 20 projectileSpeed: 20
projectileLifetime: 5 projectileLifetime: 5
energyPerAttack: 20 energyPerAttack: 20
@@ -1990,7 +1879,7 @@ CharacterController:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1202167643} m_GameObject: {fileID: 1202167643}
m_Material: {fileID: 1111001695} m_Material: {fileID: 1299771151}
m_IncludeLayers: m_IncludeLayers:
serializedVersion: 2 serializedVersion: 2
m_Bits: 0 m_Bits: 0
@@ -2008,7 +1897,7 @@ CharacterController:
m_StepOffset: 0.3 m_StepOffset: 0.3
m_SkinWidth: 0.08 m_SkinWidth: 0.08
m_MinMoveDistance: 0.001 m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 1, z: 0}
--- !u!1 &1244039457 --- !u!1 &1244039457
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2056,6 +1945,18 @@ PhysicMaterial:
bounciness: 0 bounciness: 0
frictionCombine: 0 frictionCombine: 0
bounceCombine: 0 bounceCombine: 0
--- !u!134 &1299771151
PhysicMaterial:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ' (Instance)'
dynamicFriction: 0.6
staticFriction: 0.6
bounciness: 0
frictionCombine: 0
bounceCombine: 0
--- !u!1 &1302061579 --- !u!1 &1302061579
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2126,6 +2027,38 @@ Transform:
- {fileID: 318156480} - {fileID: 318156480}
m_Father: {fileID: 1037234380} m_Father: {fileID: 1037234380}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1421129426
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 7
m_Component:
- component: {fileID: 1421129427}
m_Layer: 0
m_HasEditorInfo: 1
m_Name: arrowPos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1421129427
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1421129426}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.22, y: 0.95, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2139088647}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1451120645 --- !u!1 &1451120645
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3244,7 +3177,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: c3401c41ece280d47af5c39c99b1e31a,
type: 3}
insertIndex: -1
addedObject: {fileID: 1421129427}
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c3401c41ece280d47af5c39c99b1e31a, type: 3} m_SourcePrefab: {fileID: 100100000, guid: c3401c41ece280d47af5c39c99b1e31a, type: 3}
--- !u!4 &2139088647 stripped --- !u!4 &2139088647 stripped
@@ -3350,4 +3287,3 @@ SceneRoots:
- {fileID: 1576577255} - {fileID: 1576577255}
- {fileID: 3745968352218814396} - {fileID: 3745968352218814396}
- {fileID: 959019865} - {fileID: 959019865}
- {fileID: 1038486208}
+20
View File
@@ -111,6 +111,9 @@ public class UnitBase : MonoBehaviour
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
controller = GetComponent<CharacterController>(); controller = GetComponent<CharacterController>();
worldHealthBar = GetComponent<WorldHealthBar>(); worldHealthBar = GetComponent<WorldHealthBar>();
// 位移和朝向由 CharacterController 与 UnitBase 控制,避免攻击动画的根运动叠加旋转。
animator.applyRootMotion = false;
//记录初始坐标 //记录初始坐标
startPos = transform.position; startPos = transform.position;
randomTargetPos(); randomTargetPos();
@@ -487,6 +490,23 @@ public class UnitBase : MonoBehaviour
controller.Move(Vector3.up * getVerticalVelocity() * Time.deltaTime); controller.Move(Vector3.up * getVerticalVelocity() * Time.deltaTime);
} }
// 在 Scene 视图中标记箭的发射位置和方向,便于调整空物体。
private void OnDrawGizmos()
{
if (projectileSpawnPoint == null)
{
return;
}
Vector3 position = projectileSpawnPoint.position;
Gizmos.color = Color.cyan;
Gizmos.DrawWireSphere(position, 0.08f);
Gizmos.DrawLine(position, position + projectileSpawnPoint.forward * 0.4f);
Gizmos.color = Color.green;
Gizmos.DrawLine(position, position + projectileSpawnPoint.up * 0.15f);
}
//随机目标点 //随机目标点
private void randomTargetPos() private void randomTargetPos()
{ {