Talk:OnTrigger

Revision as of 20:37, 22 September 2008 by imported>Antares (Hopefully clarified my point about seperate OnTrigger and Gamemode Blocks inside the same script.)

Triggering Reference

How do you get a reference to the triggering object? I have setup a trigzone and want to retrieve a reference for the object responsible for the trigger. This object is added to the game dynamically.
--Antares 09:42, 7 September 2008 (EDT)

GetActionRef
Dragoon Wraith TALK 10:41, 7 September 2008 (EDT)
The Man, thanks DragoonWraith, I thought it would be something simple. I am updating the article "See Also" section for both OnTrigger and GetActionRef.
--Antares 22:36, 7 September 2008 (EDT)

BlockType Behaviour

It would appear that this function behaves like a GameMode block in that it won't run in other modes (MenuMode). I tried to use this function to circumvent an effectshader called on an object in GameMode from not being run in other modes. I needed a seperate script for this due to the dynamic nature of the object I was adding. I also needed a way to retrieve a reference to the dynamic object inside the seperate script so I thought creating a TrigZone and using an OnTrigger block would be the end of my problems, obviously not. OnLoad would work perfectly but I cannot see way to run OnLoad on a dynamic reference.
--Antares 23:34, 7 September 2008 (EDT)

Further information on BlockType Behaviour for this function: It would seem that when you try to run a GameMode block inside a script that has an OnTrigger block they will conflict. I was pulling my hair out wondering why my OnTrigger wasn't being triggered, I removed my Gamemode block because I changed my method and the code within became redundant and voila! it was all better. Just thought this would be useful information.
--Antares 02:46, 22 September 2008 (EDT)
OnTrigger (and OnTriggerActor) are Blocktypes. Blocktypes cannot be nested, i.e. nothing like this:
Begin GameMode
  Begin OnTrigger
    ;blah blah
  End
End
but only something more like this:
Begin GameMode

  ;blah blah

End

Begin OnTrigger

  ;blah blah more

End
I hope this clears that up for you? Or did you mean something else?
Dragoon Wraith TALK 11:10, 22 September 2008 (EDT)
Whoops, I should have been a bit more clear in my example. I am fully aware that you cannot nest blocktypes. If you attempt something like this you may experience undesired results:
Begin OnTrigger
 Message "Debug Message" ; so I can see if the OnTrigger block is being run at all. 
  ;do stuff here
End

Begin Gamemode
 ;condition here
  ;do stuff here
End
I had an OnTrigger block in my script to check (obviously) for when the player was colliding with my trigzone and then a gamemode block to prevent possible exploits. When writing the script I wrote the OnTrigger block first and play-tested it; no problems. I then wrote the GameMode block and began to experience problems with the OnTrigger block even being run at all. My findings implicate that OnTrigger only runs inside a GameMode block (this is backed up by results from others tests with a different application of an OnTrigger block). I hope I have cleared things up and hopefully the relevant information on the Nature of an OnTrigger BlockType can make its way into the appropriates articles.
--Antares 21:37, 22 September 2008 (EDT)
Return to "OnTrigger" page.