Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, 7th_zorro), 1,332 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Vertex Path finding/following #138262
06/26/07 16:00
06/26/07 16:00
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
This is an alternative way to create path finding/following by using vertex position
instead of traditional method.



Path creation
=============
- Firstly, fire up MED and click on "Create Vertex" button. (Step 1)

- On the top view window, move your mouse to desired position and left click
to create a vertex, this will be vertex #1 (or the first node). Repeat step 2
until all vertices (nodes) are created as you wish. (Step 2)

- Create a primitive (can be a cube, cone, or sphere) and place it in the world
centre. (Step 3) The primitive doesn't do anything to the path but if you ignore
it, you may encounter "Can't load" problem while you run the level.

- Check all vertices by clicking on "Vertex mode" and "Select" button. (Step 4)
drag and select each vertex and compare the vertex # shown on the lower right
bottom, make sure they are arranged in order. If you want to adjust the vertex
position, click on "Move" button, select and move the vertex to your desired
location. (Step 5)

- Finally name and save this model to your working directory. I call it vertexPath.mdl.

Create the level
================
- In WED, load the path model (vertexPath.mdl) and place it anywhere you want.
- Load your character/car/airplane model that will follow the path.
- Create a skybox, ground plane or any decorations if you want.
- Save and compile the level. (vertexPath.wmp)

Scripting
=========
Fire up SED and add the following codes :
Code:

//
// vertexPath.wdl
//

var video_mode = 8;
var video_depth = 32;

entity* vPath;

function main()
{
level_load("vertexPath.wmb");
wait(2);
}

action thePath
{
vPath = my;
my.passable = on;
my.invisible = on;

// Add some movement codes here....
}

define nodePos, skill1;
define nodeNo, skill4;

//uses: nodePos, nodeNo
action myCar
{
while(vPath==NULL) {wait(1);}
while(my)
{
//get next node
if (vec_dist(my.nodePos,my.x) < 35) // play with 35
{
my.nodeNo += 1;
my.nodeNo = cycle(my.nodeNo,1,9); // limited it 1 to 8

vec_for_vertex(my.nodePos,vPath,my.nodeNo);
}

//turn to new node position smoothly
vec_to_angle(temp,vec_diff(temp,my.nodePos,my.x));
my.pan += ang(temp.pan-my.pan)*0.05*time_step;

// In case you want to adjust tilt angle also
// my.tilt += ang(temp.tilt-my.tilt)*0.05*time_step;

c_move(my,vector(5*time_step,0,0),nullvector,glide); // play with 5
wait(1);
}
}



Add the script to your level in WED, assign the thePath and myCar action to the path
and the path following model respectively, compile then run. Thats it!

You may ask it won't save much workflow than the traditional pathfinding method,
I'll say yes, but I found this method very interesting and you can move the whole
path easily at runtime by adding some movement codes.

I want to share it with you because I found it quite useful, you can enchance it and
create some interesting things. For example, add a bug and let it moving around your
character's body....

You can download a demo level here

Last edited by vlau; 06/26/07 16:01.
Re: Vertex Path finding/following [Re: vlau] #138263
06/26/07 16:58
06/26/07 16:58
Joined: Mar 2003
Posts: 3,010
analysis paralysis
NITRO777 Offline
Expert
NITRO777  Offline
Expert

Joined: Mar 2003
Posts: 3,010
analysis paralysis
Quote:

but I found this method very interesting and you can move the whole
path easily at runtime by adding some movement codes.



yes that is interesting, I had never thought of that

Re: Vertex Path finding/following [Re: vlau] #138264
06/26/07 17:16
06/26/07 17:16
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Nice idea and slim solution!

Thanks for this contribution!

(Shouldn't become a poem, but here it is! )

Re: Vertex Path finding/following [Re: Pappenheimer] #138265
06/26/07 17:45
06/26/07 17:45
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Nice idea, clair explanation, great code, thxn for this helpful contribution vlau !!
I appriciate your effort

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Vertex Path finding/following [Re: frazzle] #138266
06/26/07 18:50
06/26/07 18:50
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
Cool vlau, always looking for path examples amd this one could be a real blessing for me, thanks and 5 stars man.

Re: Vertex Path finding/following [Re: Nems] #138267
06/27/07 00:22
06/27/07 00:22
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Great! Opens up some interesting possibliities. THNX.

Re: Vertex Path finding/following [Re: JazzDude] #138268
06/27/07 09:55
06/27/07 09:55
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
NITRO777, That's my point
Pappenheimer, I hope you'll find it useful someday
frazzle, You're a super nice guy!
Nems, Thanks for the stars.
JazzDude, Thanks for your kind words also.

I've another path finding/following solution, will post
it here later, stay tune!

Re: Vertex Path finding/following [Re: vlau] #138269
08/05/07 13:21
08/05/07 13:21
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Hi All,

Here is another path following/finding method. This time I use
model as a path node.

With this method, you have the following benefits :

- Drag or move the whole path at runtime
- Drag or move node at runtime
- Up to 100 skills for each node
- You can show or hide nodes

You may modify the script to fit in your game
if you like, and it's free for all.

I have added comments in the script for easy
reading, download the source under my sig.
if you're interested in it. Please note that
you need A7 to open the wmp files.

Happy coding!

Re: Vertex Path finding/following [Re: vlau] #138270
08/05/07 13:42
08/05/07 13:42
Joined: Mar 2003
Posts: 3,010
analysis paralysis
NITRO777 Offline
Expert
NITRO777  Offline
Expert

Joined: Mar 2003
Posts: 3,010
analysis paralysis
When I tried to download it the message from the server was that I dont have permissions to download it.

Re: Vertex Path finding/following [Re: NITRO777] #138271
08/05/07 13:45
08/05/07 13:45
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I think you need to register before download the
file. Sorry for the inconvenience.

Page 1 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1