[UnrealScript] Simple question

Started by
3 comments, last by Jolle 19 years, 6 months ago
Hi, I was wondering if you could clear up a little issue I'm having with UnrealScript's Trigger class. It's more of a problem understanding it rather than an issue really. Looking at the Touch function and material found in the Wiki and various other sites it would seem that when a player walks into a Triggers collision volume the trigger's Touch() method is called. The question is whether it is called continuously, that is to say upon each tick during the time the player remains in the collision volume, or simply upon entering. I have discussed the mater with members of the aforementioned communities and they are unsure or disagree. Any ideas? Many Thanks
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi
Advertisement
I believe you should treat the function as though it the event is called whenever there is contact, not just at the instance of contact.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
This is what I thought however my test shows that the Touch event is only fired upon entry into the trigger collision volume which goes against this belief. Could there be some kind of bug? or maybe I'm doing something wrong? I was expecting to see my log window fill with 'Touched' (I put a log() call in the trigger's touch event) but I only get one. :\
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi
There is a boolean variable in the trigger class called bTriggerOnceOnly. Set it to true, and it will only trigger the first time you enter the Trigger Area. Set it to false, and it will Trigger every time
By standard, the Touch function is called once upon entering. This behaviour is inherted from Actor, where Touch is defined.

All Actors also have an array of all touching actors, this can be check manually (in Tick or Timer, for preference):

var const array<Actor> Touching;

This can also be used through the iterator TouchingActors:

native(307) final iterator function TouchingActors( class<actor> BaseClass, out actor Actor );

The bTriggerOnceOnly flag defined in Trigger do not have any effect on whether or not the Touch function gets recalled the whole time while something is within the collision area, it only says whether or not the trigger will trigger once or multiple times upon leaving and re-entering.

There's this, though:

var() float RepeatTriggerTime; //if > 0, repeat trigger message at this interval is still touching other

Setting that would make the trigger to retrigger while stuff is still touching. So that means that Touch will be recalled. That seems to be what you want. But you must call super.Touch() in your Touch if you want this to work!

At least, that's what I get from reading the Actor/Trigger .uc. Hope it helps.

This topic is closed to new replies.

Advertisement