About Store Forum Documentation Contact



Post Reply 
conditionally move to waypoints?
Author Message
Chris31 Offline
Member

Post: #1
conditionally move to waypoints?
Hi, i just loaded up my first world from WE to code and did set up 1 waypoint with 7 points. I created a character which i would like to conditionally move between the points.
I get the character to move to the first point but then i dont know how to continue in my code. I tried checking the action status of the character but even when the char stops walking( he reached the point) the action status dont change from moveto(1) to none(0).
The second check i tried was to compare char.pos and Point pos but i recognized that the character`s pos vec dont exactly matches the vec of the Point.
Does anyone know what to do or is there a built-in function that handle characters moving between points?
maybe im not sure right now how the update function works within the engine.

my code in update():
PHP Code:
...

Game::Waypointwaypoint Game::World.findWaypoint(S+"0");
Vec dest waypoint->point(i).pos;
Characters[0].actionMoveTo(dest);
// if ( !Characters[0].action )
//         ++i; 
// if( Characters[0].pos() == dest )
//         ++i; 

edit: i also tried using actionMoveDir but then my char ends up in endless circling around the first point
(This post was last modified: 12-18-2009 08:08 PM by Chris31.)
12-18-2009 08:01 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #2
RE: conditionally move to waypoints?
when checking to see if a chr has reached a particular point... I get the distance of chr.pos() and the point... and then if its "close enough"... consider the chr to be there... usually like.. distance <= 0.3 ( depends on your scale...)
12-18-2009 09:29 PM
Find all posts by this user Quote this message in a reply
Chris31 Offline
Member

Post: #3
RE: conditionally move to waypoints?
thank you, how do you calculate the distance? Does it only work with the math formula:
distance = Sqrt( ( Sqr(dest.x - chrPos.x) + Sqr(dest.y - chrPos.y)+ Sqr(dest.z - chrPos.z) ) );

For many waypoints this might be an overkill?
12-18-2009 10:07 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: conditionally move to waypoints?
you can use Dist function which is basically the same
you need to calculate distance only to one, currently active waypoint
12-18-2009 10:44 PM
Find all posts by this user Quote this message in a reply
Post Reply