有没有一种方法二等于两个触发gameObjects发生冲突? [英] Is there a way two make two trigger gameObjects collide?

查看:267
本文介绍了有没有一种方法二等于两个触发gameObjects发生冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个2D游戏。

我有一个球员谁可以拍摄触发弹丸(有触发对撞机)和敌人,可以做同样的。当玩家弹丸与敌碰撞,事情发生,反之亦然。但是,当玩家弹丸和攻击弹丸碰撞,他们恰恰忽略碰撞,经过对方,并没有任何反应。他们也有连续碰撞检测Rigidbody2D。

I have a Player who can shoot trigger projectiles(with a trigger collider) and Enemies that can do the same. When a Player projectile collides with the Enemy, stuff happens and vice versa. However, when the Player projectile and the Enemy projectiles collide, they just ignore collision, go through each other, and nothing happens. They also have a Rigidbody2D with continuous collision detection.

有没有办法让它尽量事情发生时,这两个gameObjects与触发对撞机触摸?

Is there a way to make it so something happens when these two gameObjects with trigger colliders touch?

下面是我已经得到了敌人炮弹脚本:

Here's what I've got for the Enemy projectile script:

void OnTriggerEnter2D( Collider2D other ){
    if (other.gameObject.name == "Ground"){ 
        Destroy (gameObject);
    } 
    else if (other.gameObject.name == "Player"){
        other.gameObject.GetComponent<RControlScript>().RHealth = other.gameObject.GetComponent<RControlScript>().RHealth - damage;
        Instantiate(transformInto, gameObject.transform.position, gameObject.transform.rotation);
        Destroy (gameObject);
    } 
    else if(other.gameObject.name == "Shot"){
        Destroy (gameObject);
    }
}



快照作为球员抛射存在的名字该游戏物体不与敌弹碰撞。

"Shot" being the name of the Player projectile being the gameObject not colliding with the Enemy projectile.

推荐答案

是的。

下面是告诉你一个图表,什么Unity3d。

Here is a graph that tells you what collides with what in Unity3d.

这篇关于有没有一种方法二等于两个触发gameObjects发生冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆