Author Topic: sending navmesh path via rfc  (Read 3233 times)

decerto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
sending navmesh path via rfc
« on: November 06, 2015, 07:05:27 AM »
Sending a navmesh path over RFC doesn't work, returns null.

Here is what I'm doing - the host is calculating the path between the AI and the player:

  1. NavMeshPath path = new NavMeshPath();
  2. NavMesh.CalculatePath(transform.position, target.position, NavMesh.AllAreas, path);
  3. tno.SendQuickly("MoveRest",Target.All, path);

Then sends that path to everyone, so everyone is receiving it via:

  1. [RFC]
  2. void MoveRest(NavMeshPath _path){
  3.       agent.SetPath(_path);
  4.  }

The error is:
Quote
[TNet] Failed to call TNO #16775035 RFC zombieAI.MoveRest: (null)
  Expected args: UnityEngine.NavMeshPath
  Received args: <null>

But I clearly sent the navmeshpath, yet it received null.


It works for just the host, but how do I send the path to others?
Cheers

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: sending navmesh path via rfc
« Reply #1 on: November 06, 2015, 05:17:00 PM »
you need to send an appropriate variable type that tno supports.  try sending NavMeshPath as a string:

im not sure if NavMeshPath can be cast as a string - but you get the jest...

  1.  
  2. tno.SendQuickly("MoveRest",Target.All, (string)path);
  3.  
  4. [RFC]
  5. void MoveRest(string _path){
  6.       agent.SetPath((NavMeshPath)_path);
  7.  }
  8.  
  9.  

decerto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: sending navmesh path via rfc
« Reply #2 on: November 06, 2015, 05:36:20 PM »
you need to send an appropriate variable type that tno supports.  try sending NavMeshPath as a string:

im not sure if NavMeshPath can be cast as a string - but you get the jest...

  1.  
  2. tno.SendQuickly("MoveRest",Target.All, (string)path);
  3.  
  4. [RFC]
  5. void MoveRest(string _path){
  6.       agent.SetPath((NavMeshPath)_path);
  7.  }
  8.  
  9.  

Thanks but you can't convert a string to a Navmeshpath, it fails to convert. Any others ideas?

Cheers man

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: sending navmesh path via rfc
« Reply #3 on: November 06, 2015, 06:51:53 PM »
of course you cant cast NavMeshPath as a string ;p

try sending something that is supported by the TNET network object...  Vector3, int, string, etc...

for example, you could cast the nav status as a byte:  (byte)nav.status

or send each of the Vector3's:  nav.corners[0]

i'm not sure if Vector3[] will work...  seems like it should though - give it a whirl.

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: sending navmesh path via rfc
« Reply #4 on: November 07, 2015, 08:00:00 AM »
I wouldn't recommend sending the NavMeshPath at all. Instead, send the positions and have the clients calculate the path. Might run into problems with determinism (client A calculating a different path than client B), so you'd have to design around that. Why not have the host calculate the path AND move the AI / client (according to input)? I think syncing position would be easier, more secure, and you wouldn't have to worry about determinism since only one path exists - the one calculated by the host.

decerto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: sending navmesh path via rfc
« Reply #5 on: November 07, 2015, 08:52:48 AM »
Problem fixed. I sent all the navmesh.corners which is stored in a vector3 array. Then the clients simply read the vector3 corners in their path. Syncs up perfectly.

The reason why I'm just sending the path is that I only need to send it a couple or so seconds. Whereas if I send the actual position, it becomes very heavy on network calls. It simply means I can have more AI moving around now.

Thanks everyone.