What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal
RebornBuddy Forums

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Moveto

m3m3nto

New Member
Joined
Oct 20, 2015
Messages
5
Could anyone provide a short example of how to MoveTo/MoveWithin an Actor.Position using coroutines.thx
 
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.
                }
 
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.
 
Back
Top