playMaker

Author Topic: Set Agent Walkable Mask  (Read 14130 times)

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Set Agent Walkable Mask
« 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
Visit my portfolio: http://www.yanivcahoua.com/

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #1 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...

Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #2 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
« Last Edit: October 28, 2013, 02:04:42 AM by jeanfabre »

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #3 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.
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #4 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #5 on: October 27, 2013, 04:06:23 AM »
Visit my portfolio: http://www.yanivcahoua.com/

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #6 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
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #7 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #8 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
« Last Edit: October 28, 2013, 04:49:19 PM by Yanifska »
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #9 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #10 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
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #11 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #12 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
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Agent Walkable Mask
« Reply #13 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Set Agent Walkable Mask
« Reply #14 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
Visit my portfolio: http://www.yanivcahoua.com/