Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Yanifska on October 24, 2013, 04:48:20 PM

Title: Set Agent Walkable Mask
Post by: Yanifska on October 24, 2013, 04:48:20 PM
Hi !

In the Set Agent Walkable Mask action, I can't find the layer matching the value of the Nav Meshlayer Mask.
I have set a layer for Door1 ( user layer 1) and another layer for  Door2 ( user layer2).
How do I tell my character if he can navigate through these doors ?
I succeded to do this for one door by setting nothing / everything. But how to do with multiple layers ?
I just don't understand what the value is referencing, it doesn't seem to reference the layer number.

Thank you
-Yaniv
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 26, 2013, 10:39:28 AM
I am bumping this as I can't find a solution, even after rereading the manual and in the forums.
Basically what I want is that if my enemy is running for the player AND was about to cross the door THEN attack the door, or wait for the player and setup an ambush etc...

Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 26, 2013, 11:05:01 AM
Hi,

 Thanks for brining that up. Indeed it's a bit cumbersome cause you have to understand how to properly set the integer to achieve a layermask, I am not going to go into details on this, instead, I worked on creating a custom editor, now that PlayMaker allows for it!

So, install that package attached to this post on your project, and the action should now expose a new interface, with a proper layermask selection system.

 If that doesn't work as expected, let me know. If that works, I'll spread this to other actions that requires it as part of the next PathFinding update workLoad.

bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 26, 2013, 04:12:40 PM
Oh thank you so much, that looks great. I will try it tomorrow !
Even on Unity Answers nobody could help me.
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 27, 2013, 03:04:02 AM
Hi,

 Can you point me to your UA question? I'll answer. You can also fill it up yourself. It's always important to keep UA as complete as possible, so if you have an answer to your question, post it. This makes UA better.

bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 27, 2013, 04:06:23 AM
Here you go !
http://answers.unity3d.com/questions/563028/navmesh-walkablemask.html
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 27, 2013, 03:00:30 PM
Hi @Jean,

I am looking at your SetAgentWalkableMask action and  I don't understand why in the list of layer mask the layers are from the Inspector and not from the Navigation Panel.
You are providing Regular layers where I was expecting Navigation layers.
Is it a mistake or did I miss something ?

Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 28, 2013, 02:04:06 AM
Hi,

 D'oh :)

 Redownload the original package, it's fixed, let me know if it works, thanks.

bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 28, 2013, 02:17:52 PM
Hi, it works, many thanks !!
But I want to  share an idea that went while testing. ;D

The thing is I find this way of setting the layers a bit limiting.
Because If I have many doors then I can't switch between many setup since the layers has to be specified in advance in the editor...I think this is really important for the action to be really effective.

What would be great is if your action could simply add or remove a layer from the actual layer setup of the agent.

What would be event more amazing, and maybe it is too much but let me dream just a second : you could specify one or more layer and the action would update all the agents in the specified layer mask.

Just throwing ideas.....I hope they make sense.
Thank you anyway.
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 29, 2013, 02:24:00 AM
Hi,

 That's where using a simple int, would be a lot simpler, as you can compute the masking as you want.

 What I can try to do is to have actions to add remove layers to the existing walkable mask. I don't really have time right now, but would that work for you? So it would not Set the mask, but only add or remove the layer you selected.


 Bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 29, 2013, 03:19:43 AM
Let me understand,  if the door closes then  I can remove it from the mask and nobody can cross it ? And add it later when it's open again ?
 Would that be the work flow ?
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 29, 2013, 03:41:33 AM
Hi,

 no, if you cross the door, you can then edit the mask of a player ( or all player, but you will have to do it for all), and remove that layer.

Do you understand the difference? it happens as an agent level, not a navmesh level.

bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 29, 2013, 05:47:24 AM
OK, so i think it can help me indeed.
But I understand that my best shot to achieve what I need is to understand the actual Integer mystery.
Could you point to any documentation ? I begin to be curious about it
Bye,
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 29, 2013, 07:30:31 AM
Hi,

OK; let's do some binary maths!!!

http://en.wikipedia.org/wiki/Binary_number

Binary is a very powerful thing, you only have 0 and 1, and as you read a long binary number you need to think this way, lets' take an example

-- read the binary from right to left, each binary entry being indexes (n) with its integer equivalent being 2^n, n starting at 0, so the first slot on the right is indexed 0, not 1.


binary slots :  x | x | x | x
integer value: 8 | 4 | 2 | 1

so:
100 binary mean 4 as int  (4+0+0)
101 means 5 (4+0+1)

Hopefully that make sense. So to translate this to the navmesh layers in Unity

nothing - 0
everything -1
layer 0 - 1       ( built in layer 0)
layer 1 - 2       ( built in layer 1)
layer 2 - 4       ( built in layer 2)
layer 3 - 8       ( user layer 0)
layer 4 - 16     ( user layer 1)
layer 5 - 32     ( user layer 2)
layer 6 - 64     ( user layer 3)
layer 7 - 128   ( user layer 4)

so,
-- if you want to only have layer 3 ( user layer 0), the mask is 8, in binary, we would write 1000
-- if you want layer 3 AND layer 0, the mask is 8+1=9, in binary: 1001

to find out from the mask integer what layers are defined, it's bit a more complicated if you are not using binary math operators:
so we have 9:
the question to ask is:
-- what's the biggest multiple of two we can fit in 9, its 8, meaning we include layer 3,
-- we substract layer 3 we are now left with 1 (9-8)
-- what's the biggest multiple of two we can fit in 1, it's 1, meaning we include layer 0


Does that make sense? this way, with a single int, you can define a mask for any layers without risking confusion. 9 can only mean you include layer 3 and layer 0, reading the binary from right to left, 1001, we can find out visualy, that index 0 and 3 are set to 1, so layer 0 and layer 3 are included.

 :o

If you don't understand this, don't worry, get back to this and document yourself on the net and find examples to work with binary, it will start making sense if you actually use it and find real world examples.

 Bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 29, 2013, 07:56:47 AM
Oh my..... :o What the unity engineers were thinking when they designed this.
I think I can understand it if I burn a few synapses, I am not sure how I will build a working system based on that, though.
Can playmaker do binary operations ?

Thank you anyway, great explanation, long time I didn't do serious maths.
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 29, 2013, 08:26:59 AM
Hi,

 It's actually the best way to go about it, it can be considered advanced math, but nonetheless, it's very very powerful and effficient to describe such layer mask using binary, so Unity engineers did actually very well here, they albeit forgot to properly expose UI widgets to access that conviently...

PlayMaker doesn't have any binary operation, but I have added this to my todos as with a set of custom actions, it's perfectly doable actually. Right now I think the best way would be to build the two actions "add layer" and "remove layer" for the walkable mask.

Can you get back to me in few days if I haven't done them yet? thanks.

bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 29, 2013, 08:51:14 AM
Jean,
thank you so much.
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on October 30, 2013, 03:24:54 AM
Jean,
I have been advised on UA to make my door system with a traditional trigger configuration.
So don't be in a rush with the Layer Mask actions, I'll update you if the trigger based system doesn't work.
However I think you should keep it on your todo list as it makes Playmaker better.
bye,
Yaniv
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on October 30, 2013, 05:18:25 AM
Hi,

 Yep,

 Bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on November 12, 2013, 02:50:18 AM
Hi Jean,
In the end I will be needing the Add/Remove Layer action.
I got my door almost working but there are too many parameters that I am unable to manage, and using layer mask would be the easiest way to lock an area.
I hope you can work on that.
thanks
yaniv



Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on November 12, 2013, 04:23:03 AM
Hi,

 Yep, on the todo! coming after Photon is done, I have a lot of work on Photont to bring it to windows platform and follow the photon update itself, once that is submitted I can start on PathFinding.


 Bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on November 12, 2013, 04:38:36 AM
Do you have a ETA ? So I can organize my project, it's relying quite heavily on pathfinding.
Title: Re: Set Agent Walkable Mask
Post by: jeanfabre on November 12, 2013, 04:50:17 AM
Hi,

 Realistically not before mid december. If you desperatly need the add and remove layer custom action, I can squeeze that this month for sure, but a proper update of pathfinding will take a lot of time to get right.

Bye,

 Jean
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on November 12, 2013, 04:57:27 AM
I understand,
I quite have it all working, this is the only remaining issue.....for now.
So yes, If you can squeeze it, it will help me a lot I think.
Thanks in advance.
Title: Re: Set Agent Walkable Mask
Post by: Yanifska on November 15, 2013, 09:05:41 AM
Hi Jean,

I made my door mechanics from scratch using a NavMesh obstacle.
I thought there were useless, but in this specific case I got something decent results and less complicated than my previous setup.
I believe that the Unity 4.3 update and its obstacle carving feature  will help me finish this once and for all.
So It seems I won't be needing the navmesh layers for this feature.

Looking forward to trying the new 4.3
Thank you