help ontriggerenter not working c#

it doesn’t work any help
cause I put it on a cube and it went through a trigger but nothing happened no errors thought

here it is

int greg = 1;
void OnTriggerEnter (Collider other)
{
greg = 2;
}
void update ()
{
if (greg == 2)
transform.position = new Vector3(7, 0, -1);
}
}

You can check if it’s working by adding a call to Debug.Log in the function and seeing if it gets called in the console.

However, I’m betting that it’s not working because you are using

void update ()

when it should be:

void Update ()

thanks but the oncol is broken any help

The what is broken?

If it appears as if your greg is never equal 2, it might be that it is 2 but as Danial points out, you are not defining an Update(){} that gets called every frame. you defined an update(){} that is probably never called.

I fixed the update
and it still didn’t work

how is greg never equaling 2

and on trigger enter is not working
cause I used debug.log

Do both objects have colliders? Are they marked as triggers? Does at least one of the objects have an active non-kinematic rigidbody?

Yes Yes Yes

Are they using 3d colliders? If you’re using 2D colliders you need to be using

void OnTriggerEnter2D (Collider2D other) {

}

any other way to change an integer?

Cause its definittly in 2d

Im pretty sure im not missing anything

Sorry no 2d in 3d

Upload an example scene that you believe should look and someone can take a look at it and find out what’s wrong much faster.

Ok ill try