Jump to content

OnTriggerEnter and OnTriggerLeave and SE


Recommended Posts

Posted

Hi there.

It seems that using the trick of integer variable as seen in creation kit page (https://www.creationkit.com/index.php?title=OnTriggerEnter_-_ObjectReference)

is not working anymore:

 

This event can be received out of order with OnTriggerLeave, so it's ideal to keep a count instead of a simple true/false value for when things are inside the trigger.

 

Int InTrigger = 0
 
Event OnTriggerEnter(ObjectReference akTriggerRef)
    if (InTrigger == 0)
        if akTriggerRef == Game.GetPlayer()
            InTrigger += 1
            debug.notification("Entered Trigger")
        endif
    endif
EndEvent
 
Event OnTriggerLeave(ObjectReference akTriggerRef)
    if (InTrigger > 0)
        if akTriggerRef == Game.GetPlayer()
            InTrigger -= 1
            debug.notification("Leaving Trigger")
        endif
    endif
EndEvent

 

Anyone had this trouble? I'm removing this trick from all my scripts.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...