hi i use a boxcollider and a spherecollider on 1 object but use them for different things how do i check which one i enter?
These should help.
ty but now i have this
using UnityEngine;
using System.Collections;
public class GravityEnable : MonoBehaviour {
public bool InGravRange;
public PlanetGrav PG;
public GameObject Player;
public Vector3 TPPos;
void OnTriggerEnter(Collider other)
{
if (GetComponent<Collider> ().GetType () == typeof(SphereCollider)) print ("Sphere");
{
if (other.gameObject.tag == "Player") {
InGravRange = true;
PG.InGravRange = true;
}
}
if (GetComponent<Collider> ().GetType () == typeof(BoxCollider)) print ("Box");{
Player.transform.position = TPPos;
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player") {
InGravRange = false;
PG.InGravRange = false;
}
}
}

when i hit the SphereCollider it does the Boxcollider part…
Is the moving sphere the object which has the box, and sphere collider? And that is the object the above script is attached to, correct?
i might be doing something realy stupid wrong but to awnser you’re question (The cube has a Cube/sphere collider i want to check if the ball gets in the sphere or/and in the cube collider and if so do something)
Okay, so if you have more than one collider on a game object, checking the collider type will always return the first collider (which I assume is the box collider in your case).
It seems that you’ll need to have separate objects for the two triggers, since you shouldn’t have more than one per object I’m now learning.
thx it was that now i use a Empty Object to simulate the second part thx for taking you’re time to help me it was something i didnt know yet
im off to bed now and have a nice day ![]()
Yes, you could do it like that.