ID:164750
Apr 21 2007, 10:16 pm
|
|
Hello I need help creating a set movement for my mobs so they rotate freely around the town I have created. Would anyone be able to help?
|
Apr 22 2007, 3:44 am
|
|
Like...An automatic walk?
|
If I understand you correctly, you want to give an NPC a predetermined path to walk along, then when the game starts you want that NPC to continuously walk along that path. Is that correct? If so...
There are several ways you can go about this depending on the game. I will give an example of the way I usually prefer to accomplish it. First, using a datum to coordinate each movement action makes keeping track of them simple. I give the object variables to keep track of the location/direction of movement, the number of steps to take (if movement is direction rather than location), movement delay, and the next movement datum in the queue. MovePath That object can take care of a single movement-action for a movable object. An object can either walk in a specified direction for a certain number of steps, or it can be directed towards a specific object. Then the moving object needs a way to process it. All you have to do is to give the moving object a variable to keep track of its move path, and a function to execute it. atom/movable If you want the path to be a loop that the object moves around forever, as it sounds like you do, you can either have a function that calls the movement-execution inside an infinite loop, or you can just have the last movement datum in a movement queue have its 'next' variable reference the first one. Also remember that you can carry out more complex movement queues than just a simple loop. For example, you can give an object variables to reference multiple movement queues and call them in sequence. mob/guard |