🎮
24 石头人
兽人有个bug:快走到目标点时会打滑,不让怪打滑,就是需要不勾选 Nav Mesh Agent 的 auto breaking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class Golem : EnemyController { [Header("Skill")] public float kickForce = 25; public void KickOff() { a if (attackTarget != null && transform.IsFacingTarget(attackTarget.transform) ) { var targetStats = attackTarget.GetComponent<CharacterStats>(); Vector3 direction = (attackTarget.transform.position - transform.position).normalized; attackTarget.GetComponent<NavMeshAgent>().isStopped = true; attackTarget.GetComponent<NavMeshAgent>().velocity = direction * kickForce; targetStats.GetComponent<Animator>().SetTrigger("Dizzy"); targetStats.TakeDamage(characterStats, targetStats); } } }
|
攻击不到石头人的原因: 石头人中心点大于1
25 没啥可写的
26 石头人扔石头 扔出来的石头可以击打玩家一段距离
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| using System; using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Rock : MonoBehaviour { public Rigidbody rb; [Header("Basic Settings")] public float force; public GameObject target; private Vector3 diretion;
private void Start() { rb = GetComponent<Rigidbody>(); FlyToTarget(); }
public void FlyToTarget() { if (target == null) { target = FindObjectOfType<PlayerController>().gameObject; } diretion = (target.transform.position - transform.position + Vector3.up).normalized; rb.AddForce(diretion * force, ForceMode.Impulse); } }
|
错误记录:扔出的石头无法造成伤害
原因:rock预制体没有给石头赋值伤害 😓
看物体的刚体速度
1
| Debug.Log(rb.velocity.sqrMagnitude);
|
结合粒子系统
有个bug,当我走出去那个范围,石头将不会生成