how do i make this: script on 1. cheking if 2. is colliding 3.

ok, i need some help, i tried a few places and didn’t find what i was looking for, i need a script like this:

its on my camera, but checks if obj1, is colliding with an object with a certain tag

this is what i tryed:

void OnCollisionEnter(Collision retAdd){
if(retAdd.gameObject.tag == “BuildObject”)

retAdd is the object i want to chek if is colliding

You could use events


public delegate void CollisionEvent();
public static event OnCollisionEvent OnCollision;

void OnCollisionEnter(Collision retAdd)
    if(retAdd.gameObject.tag == "BuildObject") { 
       if(OnCollision != null) OnCollision();

Now on your cam:


void Awake()
    Obj1.OnCollision += OnCollisionSubscriber;

void OnCollisionSubscriber()
    print("Object collided");

The method gets called automatically when the event is happening.

If the solution above doesn’t work out for you, try this. I asked this question a few days ago and that helped me out - Collision Problem - Floor Button & Character Controller - Unity Answers