• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Moveto

    Discussion in 'Wildbuddy Developers' started by m3m3nto, Oct 29, 2015.

    1. m3m3nto

      m3m3nto New Member

      Joined:
      Oct 20, 2015
      Messages:
      5
      Likes Received:
      0
      Trophy Points:
      0
      Could anyone provide a short example of how to MoveTo/MoveWithin an Actor.Position using coroutines.thx
       
    2. Lastmango

      Lastmango Member Legendary

      Joined:
      Nov 25, 2014
      Messages:
      173
      Likes Received:
      5
      Trophy Points:
      18
      Code:
       
                      var home = new Vector3(X,Y,Z);   //Needs to be valid X,Y,Z coords
                      var CreatureId = 10000;  //Needs to be actual valid creatureId
                      var resource = GameManager.Actors.Values.Where(a => a.Position.Distance(home) <= Radius && a.CreatureId == CreatureId).OrderBy(a=>a.Distance).FirstOrDefault();
                      if (resource == null)
                      {
                          //Go Back to start to rescan
                          await CommonBehaviors.MoveWithin(home, InteractRange, true, true);
                      }
                      else if (resource.Distance > InteractRange)
                      {
                          await CommonBehaviors.MoveWithin(resource.Position, InteractRange, true, true);
                      }
                      else
                      {
                          //Do What You Came To Do
                          await Coroutine.Sleep(4000); //Sleep for 4 secs (like after a cast, or action etc.
                      }
       
    3. Lastmango

      Lastmango Member Legendary

      Joined:
      Nov 25, 2014
      Messages:
      173
      Likes Received:
      5
      Trophy Points:
      18
      Think of developing it like developing a state machine that asks you what you're doing many times per second. when you hit the async tasks it tries to decide if the task is complete or not. if not it says "Oh.. I'm still waiting for that MoveWithin task.. so I'm good"

      so your logic in your Pulsed routine has to know your state, and what you're doing every single time it gets pulsed. Simple states are handled with if/elseif/else tags.

      More complex states and I've typically developed internal singleton state machine tracking classes.
       
    4. m3m3nto

      m3m3nto New Member

      Joined:
      Oct 20, 2015
      Messages:
      5
      Likes Received:
      0
      Trophy Points:
      0
      Thanks for help
       

    Share This Page