Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: ylegrand on July 08, 2017, 08:22:09 PM

Title: Global region's events handling
Post by: ylegrand on July 08, 2017, 08:22:09 PM
Hi WME community!

I'm currently working on my first WME game and I'm facing to a problematic I'm not able to solve myself.

In my scene, there are floors and ladders. I'm able to change the actor animation for the ladder by creating for each ladder region the following dedicated script :

Code: [Select]
on "ActorEntry"
{
actor.WalkAnimName ="ladder";
}
on "ActorLeave"
{
actor.WalkAnimName ="walk";
}

It works fine, but as I'll have a lot of ladders, I was wondering if there is a way to add an event listener on ALL the regions, and to code the conditionnal logic inside. I have in mind to :
Code: [Select]
on "ActorEntry"
{
 if (this.ladder != null){
actor.WalkAnimName ="ladder";
  }
}

First of all, does it make sense to the WME profesionnal you are?
If yes, could you please help me to do it ?

Thanks a lot for your time !
Title: Re: Global region's events handling
Post by: anarchist on July 09, 2017, 01:20:33 PM
Instead, why not create a single ladder.script and use the first piece of code you showed us in that script? Then you would assign this same script to all your ladder regions. If you want one of your ladder regions to do something different than the other ladders on ActorEntry then you can use the custom properties to program the behaviour.

Good luck with your first WME game!
Title: Re: Global region's events handling
Post by: ylegrand on July 09, 2017, 01:34:11 PM
Thanks for your quick answer!

It's indeed a good compromise. I'll do like this by waiting to know if a global region's events listener exists or not.
Title: Re: Global region's events handling
Post by: Mnemonic on July 09, 2017, 01:45:24 PM
No, there is no global event listener for this. But I believe anarchist's suggestion is a very valid replacement.
Title: Re: Global region's events handling
Post by: ylegrand on July 09, 2017, 02:17:17 PM
So thanks guys, question solved :)