unity ParticleSystem collidesWith 碰撞
Unity ParticleSystem collidesWith
我正在尝试更改脚本内粒子系统的 collidesWith 参数,但出现此错误:
Error CS1612 Cannot modify the return
value of 'ParticleSystem.collision'
because it is not a variable
我的代码:
GameObject ammo; //Game object with ParticleSystem on it
public LayerMask desiredLayers;
private void Start()
{
ammo.GetComponent<ParticleSystem>().collision.collidesWith = desiredLayers;
}
现在我的问题是改变粒子系统碰撞层的正确方法是什么。
好吧,我明白了,显然 ParticleSystem 是 属性。
Unity 有一些特殊的 ParticleSystem,它使用指针,所以下面的代码解决了我的问题:
var collidesWith = ammo.GetComponent<ParticleSystem>().collision.collidesWith;
collidesWith = desiredLayers;
我正在尝试更改脚本内粒子系统的 collidesWith 参数,但出现此错误:
Error CS1612 Cannot modify the return value of 'ParticleSystem.collision' because it is not a variable
我的代码:
GameObject ammo; //Game object with ParticleSystem on it
public LayerMask desiredLayers;
private void Start()
{
ammo.GetComponent<ParticleSystem>().collision.collidesWith = desiredLayers;
}
现在我的问题是改变粒子系统碰撞层的正确方法是什么。
好吧,我明白了,显然 ParticleSystem 是 属性。
Unity 有一些特殊的 ParticleSystem,它使用指针,所以下面的代码解决了我的问题:
var collidesWith = ammo.GetComponent<ParticleSystem>().collision.collidesWith;
collidesWith = desiredLayers;