- Home /
Connect a collider with a rigidbody ??
Hello!
I'm trying to make an object inside the rigidbody detect a collision (if or if you need a rigidbody but I can't add that component in a child object).
and it only remains that you can connect them via script so that it detects the rigidbody, but the collider too (the script is in the collider).
using UnityEngine;
using System.Collections;
public class Damage_Script : MonoBehaviour {
public GameObject NoDamage;
public GameObject Damage;
public GameObject CollisionObject;
void Start ()
{
}
void OnCollisionEnter(Collision col)
{
CollisionObject = col.gameObject; // I put this to know what I collide with
if(col.gameObject.tag == "Untagged")
{
NoDamage.SetActive(false); // Deactivate the undamaged object
Damage.SetActive(true); // Activate the damaged object
}
}
}
Is there any way? Thank you!
Answer by wewewu · Jun 09, 2020 at 05:14 AM
I think adding a Rigidbidy to a GameObject will also detect collision in it children.
I tried to do it before, I even tried with kinematic and "on trigger enter", but it did not work well.
you should add a few more details. How are the objects arranged in the hierarchy? Which of those has the rigidbody?
which should detect the collision?
In the hierarchy is: Rigidbody (The Car)
Inside is a gameobject with 4 invisible cubes, which should detect its own collision, each of them carries the script.
Your answer
Follow this Question
Related Questions
Colliding fast moving object with a slow moving object 1 Answer
Child colliders affecting parent rigidbody characteristics? 0 Answers
Parent rigidbody using its childrens colliders. Should it work or am I stupid? 2 Answers
Why does my player fly through my barrier? 2 Answers
Collisions While Rotating Objects Without Character Controllers 1 Answer