#triggers

1 messages · Page 1 of 1 (latest)

ancient dagger
#

hey guys im having some truobles you see i have 2 box colliders set to trigger but they bioth do the same thing when i want them to do diffrent things

celest bear
#

use different scripts and two different gameobjects?

ancient dagger
#

i did

#

ill try explain more in depth gimme a sec to type

celest bear
#

ok..

ancient dagger
#

so basically what i have is 2 seprate game objects both with trigger colliders as seen in the first screen shot however if i enter lets say the back one whic has a script on it it does the exact same thing as the closer on even though they have seprate scripts

celest bear
#

are they on teh same parent?

ancient dagger
celest bear
#

i dnt think that would matter tbh

ancient dagger
#

yes but diffrent objects

celest bear
#

what happens if u disable one?

#

and test the other

ancient dagger
#

nothing

#

it still keeps doing the thing where it shows the forst stuff

celest bear
#

whats the script for the front one?

ancient dagger
celest bear
#

umm what ur saying dont make sense... if u disable 1 the other 1 does what the 1 u disabled did..

ancient dagger
#

yup

#

i could try stream it to you if you want

celest bear
#

i dont think that'd help me understand whats going on

ancient dagger
#

broo i just realised who you are i was watching your vids the other day

celest bear
#

for 1 ive never seen anyone use Monobehaviours like that..

ancient dagger
#

epik

celest bear
#

OnTriggerEnter only happens the frame that u step into that collider

#

so.. in that code it'd run that whole block instantly... and unless u were a super human its doubtful u can press the L key down at the exact same frame

#

OnTriggerStay would run every frame u were in that trigger zone

#

so in that case u could listen for a keypress in that block

ancient dagger
#

okthanks

celest bear
#

np, if u change that out real quick u could retest that script

#

and then u could eliminate 1 error point in ur code u got now

celest bear
#

put a debug log in it

#

inside the OnTriggerStay but not inside the keypress check

#

or u could put a debug in both places and see which one/or any run

ancient dagger
#

ok

#

so i fixed the part where the first script i sent u wasnt working but now i have the problem where both boxes can do both things

celest bear
#

yea that part is still puzzling to me

ancient dagger
#

ok

celest bear
#

can you screenshot the inspector

ancient dagger
#

ok

celest bear
#

of the box colliders expanded.. and the script u have below it

ancient dagger
#

the first one is the long script and the second is the shorter script

celest bear
#

so this gameobject

#

has this attached to it.. but it doesn't have a trigger collider anywhere on that object

ancient dagger
#

yes

#

ok i will fix that but it works anyway

#

ok so know it has a trigger collider