Results 1 to 12 of 12

Thread: Simple Path Movement

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lesser Wizard
    Join Date
    Mar 2008

    Default Simple Path Movement

    OK. So, I have a sprite which I want to move up and down the play area. Applying some of the techniques I learned in the Dragon Eggs tutorial I setup two waypoints and applied the following script to the sprite:

    function OnMapInsert() //run as the entity is placed on an actual map, but before OnPostInit()
    	GetWatchManager:Add(this, C_TIME_FOREVER); //always function offscreen
    function OnInit() //run upon initialization
    	//hint to the path-finding system that it can ignore this while computing paths if it needs to
    function OnPostInit() //run after being placed on a map
    function OnKill() //run when removed
    function AddPatrolGoals()
    	//let's make him move to the four checkpoints
    	this:GetGoalManager():AddApproach(GetEntityByName("Ele1B"):GetID(), C_DISTANCE_CLOSE);
    	this:GetGoalManager():AddApproach(GetEntityByName("Ele1A"):GetID(), C_DISTANCE_CLOSE);
    The sprite is positioned at the top of the screen, as is waypoint Ele1A. Using this code I would hope for the entity to move down (to waypoiny Ele1B) the screen and back up.

    The problem is that there are some entities in the way, and the sprite attempts to maneuver its way around these entities (and eventually gives up when it reaches a solid platform). I though I could get around this by assigning the sprite to layer "Overlay 1", but this does not seem to help.

    Any ideas on what I can do to just bring this sprite up and down the screen?

  2. #2


    hi pleng,

    i'm no expert by any means, so take this for what it's worth, but you may have to set up more path nodes to give your sprite more choices of how to navigate to the way points, then it might not get hung up on obstacles.

    someone please correct me if i'm wrong.

    good luck pleng

  3. #3
    Lesser Wizard
    Join Date
    Mar 2008


    Hi Harrio.

    Thanks for you response.

    Yes, adding pathfinding nodes will help the sprite move around obstacles. However I want my sprite to go directly from point A to point B, ignoring any obstacles. Think, as an example, of moving platforms in games such as Sonic the Hedgehog. These will follow a fixed path regardless of any other player, enemy, or other background obstacles which might be in the way.

  4. #4



    i think i understand now. i misinterpreted what you were saying. you want a non-player entity to move on a fixed path. i think, you can have it ignore collisions, but you will have to deal with how it interacts with player entities, maybe by increasing it's density or simply being rendered over or under the players.

    hope that helps.

  5. #5
    Lesser Wizard
    Join Date
    Mar 2008


    i think, you can have it ignore collisions,
    Ok thanks. How do I go about doing that?

  6. #6
    Administrator Seth's Avatar
    Join Date
    Jul 2002


    Hmm... well, one solution is to not give it enough nodes to make any 'choices' so a platform can't avoid anything.

    I threw a platform into the treeworld example to illustrate this. (see pic)

    Another option would be to handle the movement without using the pathfinding system - you could still use your same start/end marker tags, but handle the actual movement by calling AddForceConstant() each update tick.

    Warning: In general, the pathfinding stuff is not going to work with the sideview things as far as AI movement, as it doesn't understand things like ladders and jumping.
    Attached Images Attached Images  
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Relative File Path
    By Dr. Rain in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 03-08-2008, 01:05 AM
  2. Simple Animation
    By ares in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 02-27-2008, 05:20 AM
  3. simple ClanLib example problem - segfault
    By phx_one in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 02-17-2008, 12:54 AM
  4. Program Dies from Player Movement
    By catch22 in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-03-2007, 06:08 AM
  5. Simple app won't compile when linked with clanlib
    By mmiikkee12 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-17-2007, 02:41 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts