- Home /
hollow cone collider has no end caps
Hi I cannot detect a collision, only if another object touches the cone wall, the goal is if an object passes the cone and does not touch it it must not have "is Trigger" enable collision
I am terribly sorry but I am having a difficult time following what you wrote. Could you perhaps rephrase your question?
Answer by SadeqSoli · May 31, 2021 at 02:49 PM
Hi @ marwabengadem , First of all make sure each object have collider to trigger it when they collide. Another important point is that when you use OnTriggerEnter Method you should check the "isTrigger" Boolean on your collider and when you want to detect collision with OnCollision Method you should make sure that the "isTrigger" Boolean is OFF. this is the condition for it and it should work.
Answer by marwabengadem · May 31, 2021 at 09:06 PM
thank you , i have problem with colider cone , the colider mesh is not detect as hollow cone, but like a simple cone
i want a detection if only other object hit the mesh cone that i create
i dont know if you can understand me :/
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class colider : MonoBehaviour {
private void OnTriggerEnter(Collider other)
{
Debug.Log("hit detected");
GetComponent<Renderer>().material.color = Color.blue;
}
}
Hi again, You can do this if you want to catch something like enemies:
private void OnTriggerEnter(Collider other)
{
//get objects by tag
if (other.CompareTag("targetTag"))
{
//do something
//
//you can use it like bottom Or anything else.
EnemyScript enemyScript= other.gameObject. GetComponent<EnemyScript>();
enemyScript.CallDestroy();
}
//get objects by name
if (other.name == "targetName")
{
//do something
}
}
//when collision happens
private void OnCollisionEnter(Collision collision)
{
//get objects by tag
if (collision.gameObject.CompareTag("targetTag"))
{
//do something
}
//get objects by name
if (collision.gameObject.name == "targetName")
{
//do something
}
}