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!