【发布时间】:2018-08-11 23:36:57
【问题描述】:
在 Untiy 2018.2.2 中加载我的 Unity 2018.1.1 项目后,OnParticleCollision 方法根本不会被触发。在 Unity 2018.1.1 中一切正常。
没有关于更新粒子碰撞的官方信息。
这是我的 Enemy 脚本的 C# 代码。
Player GameObject 具有用作武器的粒子系统 + Collision 模块已启用并已正确设置为与 Enemies 层发生碰撞。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
// Enemy health
private int health = 100;
// !!! Doesn't get triggered at all !!!
// When the player's weapon hits the Enemy
private void OnParticleCollision(GameObject other)
{
Debug.Log(other.tag);
if (other.tag == "Weapon")
{
// Reduce health
health -= 50;
if (health <= 0)
{
// Disable the Enemy that was just killed
gameObject.SetActive(false);
}
}
}
}
【问题讨论】:
-
选择粒子系统,确保 Collison 模块已启用。现在确保它的 "Send Collision Messages" 也已启用。
-
是的,它已启用。正如我上面提到的,Unity 2018.1.1 中的一切都完美无缺
-
检查游戏对象是否仍有“武器”标签。有时会发生在版本升级之间,游戏对象标签丢失。
标签: unity3d