Unity学习变量脚本怪物追玩家凝雨2024-03-302024-09-10怪物跟踪算法123456789101112void Update() { if (player != null) { // 计算怪物和玩家之间的方向向量 Vector2 向量= (玩家.position - transform.position).normalized; // 移动怪物 transform.Translate(direction * 速度* Time.deltaTime); } }