How to use onTriggerEnter and onCollisionEnter in Typescript

Ok found

by user 224464722878005248

Yes ok
I found my error

We need to drag the script in the player, and drag the player script in the object serializable of your onEnter() !

by user 224464722878005248

by user 224464722878005248

(for others)

by user 224464722878005248

All of my triggers as launched when I instantiate them (without be trigger by a SpartialTriggerReceive), do you know why ?

by user 224464722878005248

What do you mean?

I generate my terrain by instantiate new “blocs”
It makes the road
When I instantiate it, It activates the function in spatial trigger Receive, without any collision

by user 224464722878005248

(only on beggining)

by user 224464722878005248

For example, I generate the first 8 blocs of my road to begin
There is one spatial trigger by bloc which (for example) call console.log(“I’m trigger”) when it’s triggered by a Trigger spatial receiver on the player

My player is in the 0 0 0 position
My road is composed by my blocs, blocs in 20, 50… 80 (bloc of 30x30) position so there is any collision between the player which has the trigger spatial receiver

But I could see 8x “I’m triggered” on my console

by user 224464722878005248

Do you think you can make a small repro (a minimal scene) so I can look into it?

When I create new blocs it’s ok !
The trigger is activate only by collision
But the beginning it’s space

by user 224464722878005248

Ok

by user 224464722878005248

Thanks! :slightly_smiling_face:

Maybe its something I fixed a bit earlier today - the code for checking the box intersections didnt report intersections in some cases (e.g. with multi materials or weird scales)

Hmm
The bug is gone… weird…

by user 224464722878005248

:thinking:

I will send it if the bug comes back ^^

by user 224464722878005248

What did you change?

It’s because I put trigger on one of my bloc, a corner, to rotate the terrain when my player receive the trigger

I put 3 of them, one by corridor
And When I instantiate my road, I could see all of triggers activate the function rotation without any colision

But 2 problems : my rotation doesn’t work (my section rotation seems to by incremented but my gameobjects childs of the Sections don’t move so…) + the scripts bug was here
So I delete the triggers

I tried to remake a simple example like this :

by user 224464722878005248

by user 224464722878005248