HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: NPC movement, _PathSystem  (Read 2270 times)

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
NPC movement, _PathSystem
« on: Jun 19, 14, 12:35:32 PM »

Hello all!

My NPC's when they explore a map, they get a random point on a map and move there.

I have such problem: sometimes my NPC's move throw model's or they move very close to some model so some part of NPC model can be inside some model.

At first, i thought the problem was in PathSystem : i try to get path with default walkable parameter

Default walkable parameters (in _PathSystem, method - _pathSystem_GetWalkableParameterSetHandle ):
Quote
AddKeyValueSpec("_GroundedPath","char_width      = float,0.03,0.01,1         # The character width")
      AddKeyValueSpec("_GroundedPath","char_height     = float,0.165,0.01,1        # The character height")

Default parameters for char_width is - "char_width  = float,0.03,0.01,1 ", so i create my own method for this purposes.

This is the way, i get path
Quote
handleID as ID = me._GetWalkableParameterSetHandle()
  me.pathRequestID = $PathSystem._PathSystemGetPath( me, handleID, me.GetPosition(), pos )

My implementation of _GetWalkableParameterSetHandle() :
Quote
method _GetWalkableParameterSetHandle() as ID
  parameterSetHandle as ID
  handled as Boolean
  if hasMethod( me, "HE_pathSystem_GetWalkableParameterSetHandle" )
    handled = me.HE_pathSystem_GetWalkableParameterSetHandle( parameterSetHandle )
  .
 
  if not handled
    if ( not DoesKeyValueSpecExist("NPC_GroundedPath"))
      CreateKeyValueSpec("NPC_GroundedPath","")           // Creates a named KeyValueSpec called 'GroundedPath'
      AddKeyValueSpec("NPC_GroundedPath","step_value      = float,0.05,0.01,0.4       # Distance between smoothed data points")
      AddKeyValueSpec("NPC_GroundedPath","tightness       = float,0.1,0.1,100         # Distance between control points")
      AddKeyValueSpec("NPC_GroundedPath","check_above     = float,4.0,0.01,100        # Height above to start grounding")
      AddKeyValueSpec("NPC_GroundedPath","walk_slope      = float,45,1,85             # Walk slope for the character")
      AddKeyValueSpec("NPC_GroundedPath","char_width      = float,0.65,0.65,0.65         # The character width")
      AddKeyValueSpec("NPC_GroundedPath","char_height     = float,0.65,0.65,0.65        # The character height")
      AddKeyValueSpec("NPC_GroundedPath","collision_group = string,CGF_PATH_COLLISION # Specifies the collision group flags to use.")
      AddKeyValueSpec("NPC_GroundedPath","debug_visualize = boolean,false             # True to debug visualize the smoothed path.")
      AddKeyValueSpec("NPC_GroundedPath","string_pulling    = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","terrain           = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","non_terrain       = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","water             = boolean,false           # ")
      AddKeyValueSpec("NPC_GroundedPath","underwater        = boolean,false           # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid1       = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid2       = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid3       = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid4       = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer1      = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer2      = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer3      = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer4      = boolean,true            # ")
      AddKeyValueSpec("NPC_GroundedPath","dive_down         = boolean,true           # ")
      AddKeyValueSpec("NPC_GroundedPath","swim_up           = boolean,true           # ")
      AddKeyValueSpec("NPC_GroundedPath","dive_down_cost    = float,1,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","swim_up_cost      = float,1,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","terrain_cost      = float,1,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","non_terrain_cost  = float,1,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","underwater_cost   = float,1,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid1_cost  = float,2,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid2_cost  = float,4,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid3_cost  = float,6,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","path_avoid4_cost  = float,8,0.1,100         # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer1_cost = float,0.2,0.1,100       # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer2_cost = float,0.4,0.1,100       # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer3_cost = float,0.6,0.1,100       # ")
      AddKeyValueSpec("NPC_GroundedPath","path_prefer4_cost = float,0.8,0.1,100       # ")
      AddKeyValueSpec("NPC_GroundedPath","time_out          = float,4,0.2,120         # ")
      AddKeyValueSpec("NPC_GroundedPath","priority          = integer,1,1,10          # ")
    .
    parameterSetHandle = GetKeyValueSpecDefaultData("NPC_GroundedPath")
  .
 
  return parameterSetHandle
.

I changed char_width to 0.65 (this is real width of my character), but i got no changes, my NPC's steel sometimes go throw objects, ot some part of NPC was in some model.


At second, i thought, maybe this something wrong on a client side? And on a client i found a place, where i receive a path for my NPC (E_ACCServerControl), and found that my path was smoothed that way:
Quote
data as ID =createKeyValueData("NPCGroundedPath","step_value=.05,tightness=15,check_above=4,walk_slope=45,char_width=0.03,char_height=0.03,collision_group=CGF_PATH_COLLISION")
  DoPathSmoothing(smoothPointList, newPointList, data)

So i change width to 0.65 and heigh to 0.65, but this not help me.


At third, i visualised (DrawDebugPoint :) ) a path, that i received from server. And this path really go very close to wall's or some other models.


My fourth step was : i decide to rebuild all navmesh for this area with a new parameres, so i open "Path Planning" panel and... i don't found there tab - "Custom Path generation Properties" . In wiki I read, that if i change the defaultnavmesh.ini, a new nav mesh will be generated for all area. I try it too... but there were no changes. NavMesh don't want to rebuild themself)  (i don't forget to change version up by one)


What you will recomend for me?) I think if i rebuild a NavMesh with another path parametrs like:
 character_width            = 0.65          # The width of the charater (game units)
My NPC's will not move trow models(
« Last Edit: Jun 19, 14, 12:38:18 PM by __BVS__ »
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #1 on: Jun 19, 14, 01:02:58 PM »

you need to look into the client side path smoothing routine. this external function tends to put the models on paths that cut corners , door frames etc.

you can bypass it , you just need to reorder your points for the next section of code and comment out the call to the external path smooth function.
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #2 on: Jun 20, 14, 06:05:14 AM »

WorldWideZ, thx for u reply, but i try it too.

Quote
At third, i visualised (DrawDebugPoint :) ) a path, that i received from server. And this path really go very close to wall's or some other models.

I visualized a path "A", that i received from server, and smoothed path "B", that "DoPathSmoothing" external function made for NPC.  And what i saw : control points for path "A" sometimes too close to some models (walls, containers...) or if I join them (point's of path "A") in a chain (DrawDebugLine ..) i saw that some piceses of my path are lie throw cornes of models or very close to some models (if character go on this path he will 100% touch a wall/container/car ...

I change code of UpdatePathPoints (E_ACCServerControl) to use onle path "A" , that I received from server. And as i say before, my NPC steel cut the corners or go very close -_-

Next step, i try to change on the server this parameters in my _GetWalkableParameterSetHandle() :

Quote
AddKeyValueSpec("NPC_GroundedPath","step_value      = float,0.01,0.01,0.01       # Distance between smoothed data points")
      AddKeyValueSpec("NPC_GroundedPath","tightness       = float,0.02,0.02,0.02         # Distance between control points")

But nothing happend. I didn't receive more detail path with a huge amount of point's, i received a path where distance between point's can be greater then 4.0 !



What can u recommend me ? Can anybody explain me - "tightness       = float,0.02,0.02,0.02 " - Why are three parametres needed in this line? maybe I do something wrong, when i feel them that's way ?




P.S: Where can i found - "Custom Path generation Properties" panel? I look everywhere and can't find it, in "Hero Engine 1" it was in "Path Planning" panel, but not now(

« Last Edit: Jun 20, 14, 06:06:46 AM by __BVS__ »
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #3 on: Jun 20, 14, 06:19:12 AM »

what does your nav mesh look like when its turned on? it is important to note that the nav mesh does not always auto generate on the  fly , unless you have update dirty areas on. a screen shot of the nav mesh around one of the objects would be handy.
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #4 on: Jun 20, 14, 06:48:27 AM »

All images are clickable :)







This is my Path Planning Panel, in previous version of Hero Engine i could change my defaultnavmesh.ini in this panel, but not now. Where is "Custom Path generation Properties" ? If i change defaultnavmesh.ini via repositoriy browser, no changes aplly(

Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #5 on: Jun 20, 14, 07:42:43 AM »

the only way to get the ini to update in engine is to make the changes and then wait for the server to sleep , and then on restart it will re generate the nav meshes. this can take a long time. though some experimentation we found reducing the distance between points gave better results around scenery, but it will cost you more time getting a response from the physics server , which means some system of managing the requests that go out to it.
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #6 on: Jun 20, 14, 08:18:58 AM »

I will try your solution how to rebuild a NavMesh, i hope it will help me:)


Can anybody explain me :
Quote
I try to change on the server this parameters in my _GetWalkableParameterSetHandle() :

Quote
AddKeyValueSpec("NPC_GroundedPath","step_value      = float,0.01,0.01,0.01       # Distance between smoothed data points")
      AddKeyValueSpec("NPC_GroundedPath","tightness       = float,0.02,0.02,0.02         # Distance between control points")

But nothing happend. I didn't receive more detail path with a huge amount of point's, i received a path where distance between point's can be greater then 4.0 !
Why didn't any changes happen? Why did i receive a path with distance between points more then 0.02 ?


And second question :
Quote
Can anybody explain me - "tightness       = float,0.02,0.02,0.02 " - Why are three parametres needed in this line? maybe I do something wrong, when i feel them that's way ?
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #7 on: Jun 20, 14, 09:16:28 AM »

if it was immediately after changing with out a client / area / world server restart you would not see a change , i think the key values are set at start up. its one of the reasons the path system can be hard work as you can make lots of changes with out causing a effect untill the restart thats needed happens.
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #8 on: Jun 20, 14, 10:09:23 AM »

I renamed in all places "NPC_GroundedPath" to "NPC_GroundedPath_temp1" :) So it create a new KeyValueSpec with name "NPC_GroundedPath_temp1", but nothing changed x_X
For example I changed "tightness" to 0.02 but distance between point of path is more then this value, for some points - 4.0 and greater. So it look's like a bug in pathfinder...
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #9 on: Jun 23, 14, 05:35:08 AM »

if it was immediately after changing with out a client / area / world server restart you would not see a change , i think the key values are set at start up. its one of the reasons the path system can be hard work as you can make lots of changes with out causing a effect untill the restart thats needed happens.

I try to restart server, but nothing heppend with Navigationmesh =(  It doesn't use  a new navmesh file...
« Last Edit: Jun 23, 14, 07:21:42 AM by __BVS__ »
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #10 on: Jun 23, 14, 11:32:44 AM »

in path planning panel , check near the bottom , there should be a list of areas. depending on how many areas you have will effect how long it takes to regenerate the nav mesh. Due to the vitualised nature of the cloud you have one physics server that is doing all the work , and this can take a long time. like maybe a week. depends on what settings you plug in really , i have forced it to have far more points than is suggested and it took forever to finish adjusting. turn on the visualization and redraw dirty regions , then move something to cause it too dirty up and it will regenerate locally with the new ini settings.
Logged

__BVS__

  • Developers
  • *
  • Posts: 15
    • View Profile
Re: NPC movement, _PathSystem
« Reply #11 on: Jun 24, 14, 10:26:01 AM »

Quote
in path planning panel , check near the bottom , there should be a list of areas.

There is nothing =( 



Can u publish a screenshot of your pannel ?
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: NPC movement, _PathSystem
« Reply #12 on: Jun 25, 14, 03:38:03 AM »

ok got some screens for you

Code: [Select]
                                  ##########################################
# This INI file defines the properties #
# that control how the naviation mesh  #
# for an area is created.              #
##########################################
[DEFAULT]

build_version              = 30            # Bump this number to force the build of the Navigation Mesh for this area.
terrain                    = true         # True if path finding nodes allowed on terrain
non_terrain                = true          # True if path finding nodes allowed on non-terrain

water                      = true          # True if path finding nodes allowed on the surface of water
underwater                 = true          # True if path finding nodes allowed underwater
dive_down                  = true          # True if dive-down connections allowed
swim_up                    = true          # True if swim-up connections allowed

avoid1                     = true          # True if path finding nodes allowed on 'avoid1' type objects
avoid2                     = true          # True if path finding nodes allowed on 'avoid2' type objects
avoid3                     = true          # True if path finding nodes allowed on 'avoid3' type objects
avoid4                     = true          # True if path finding nodes allowed on 'avoid4' type objects

prefer1                    = true          # True if path finding nodes allowed on 'prefer1' type objects
prefer2                    = true          # True if path finding nodes allowed on 'prefer2' type objects
prefer3                    = true          # True if path finding nodes allowed on 'prefer3' type objects
prefer4                    = true          # True if path finding nodes allowed on 'prefer4' type objects

character_capsule          = true          # True if the character controller is a capsule
character_walk_slope       = 35            # The valid walk slope for the character
character_width            = 0.02          # The width of the charater (game units)
character_height           = 0.17          # The height of the character (game units)
character_step_height      = 0.06          # The step height of the character

node_granularity           = 0.03          # The granularity of a single unit for node generation (game units)
node_min                   = 2             # The minimum size for a node (number of granular units)
node_max                   = 2             # The maximum size for a node (number of granular units)

connection_search_distance = 8.0         # The distance allowed to search for connections (game units)
connection_search_count    = 20             # The maximum number of nodes to search connections for.
connection_max             = 8             # The maximum number of connections to keep for a single node.

Thats my nav mesh ini. bear in mind this is the default nav mesh and there are ways to have more than one (although i have not got them working yet to my satisfaction) note the build number at the top , you must increase this to get it to notice any other changes.

below is my path planning panel , with a bunch of stuff going on. note to get instant changes to the nav mesh (or seemingly any changes under current version , not sure if its always worked this way) you need to enable update dirty regions.

Logged