Jump to content
  • Advertisement
Sign in to follow this  
algorhythmic

[UnrealScript] Simple question

This topic is 5460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. :\

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!