玩家的孩子没有检测到与其他物体上的刚体的碰撞 [英] Child of Player not detecting collision with rigidbody on other object

查看:30
本文介绍了玩家的孩子没有检测到与其他物体上的刚体的碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有角色控制器的玩家,以及一个带有胶囊碰撞器的子对象,从玩家的 characterController 伸出一点点,以检测玩家是否跳上带有刚体的立方体.玩家的孩子有一个叫做锤子"的标签,刚体立方体上面有一个脚本.

I have a player with a character controller, and a child object with a capsule collider extending a little bit out of the player's characterController to detect if the player jumps on a cube with a rigidbody on it. The child of the player has a tag called "hammer", and the rigidbody cube has a script on it.

出于某种原因,孩子没有检测到与刚体的碰撞.只有当玩家和孩子接触刚体时才会这样做.这是刚体立方体的代码:

For some reason, the child is not detecting collisions with the rigidbody. It only does so when the player and the child is touching the rigidbody. Here is the code for the rigidbody cube:

private void OnCollisionEnter(Collision other) {
   if(other.collider.tag == "hammer") {
       Destroy(gameObject);
   }
}

注意: 不能向播放器添加刚体,否则会像 spazzling 一样过时.

NOTE: Can't add rigidbody to player otherwise spazzles out like spazzling is going out of style.

推荐答案

只需要在child和tag上加刚体,不需要在外部对象上加刚体.

Just needed to add rigidbody on the child and the tag, and didn't need the rigidbody on the external object.

这篇关于玩家的孩子没有检测到与其他物体上的刚体的碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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