path_create doesnt work

Posted By: Bone

path_create doesnt work - 04/27/11 14:00

I tried to create a path with path_create and an entity that
follow the path.

var 'check' and 'node' are always 0
I write this again so you dont forget it wink

Code:
var dist = 0;
	
	ENTITY* ball = ent_create("ball.mdl", vector(0,0,20),NULL);
	
	path_create(ball,4,4);
	
	var check = path_setnode(ball,1, vector(0,30,20),NULL);
	path_setnode(ball,2, vector(3*60,3*30,70),NULL);
	path_setnode(ball,3, vector(7*60,4*30,50),NULL);
	path_setnode(ball,4, vector(11*60,2*30,20),NULL);
	

	while(1){
	 	var node =	path_spline(ball,ball.x,dist);
	 
	 	dist += 5*time_step;
		DEBUG_VAR(check, 10);
		DEBUG_VAR(node,22);
	
		wait(1);
	}


Posted By: jcl

Re: path_create doesnt work - 04/28/11 15:45

Thanks - it was indeed a bug. Path creation did not work when you use an empty level.

This will be fixed.
Posted By: Bone

Re: path_create doesnt work - 04/28/11 18:06

You are right. I tried it with level_load("");.
With loading an empty wmb file it works.

Why is path_create limited to 256 Nodes?
Posted By: Bone

Re: path_create doesnt work - 05/06/11 16:57

An other problem.
I want to receive the name of a path (with path_set()) which i created with path_create() and use it in ent_movepath()

road1.track_path is an ENTITY Pointer with an model attached to a path.
Code:
function move_car()
 {
 	
 	ENTITY* car = ent_create("mini.mdl",0,0);
  	STRING* tpath;
 	path_set(road1.track_path,tpath);
 	printf(_chr(tpath));
 	ent_movepath(car,tpath, 5,2);
 	 	
}



printf shows me some crazy symbols an the car dont move
along the path.

Also a bug or my fail?
Posted By: Uhrwerk

Re: path_create doesnt work - 05/06/11 19:17

Your fail. tpath has not been initialized and hence is a vagabonding pointer. Use
Code:
STRING* tpath = str_create("#32");
// The rest of your code goes here...
ptr_remove(tpath);


instead.
Posted By: Bone

Re: path_create doesnt work - 05/06/11 20:42

I tried this too and it doesnt work.
printf() shows a blank box and the entity isnt moving along the path.
Posted By: Superku

Re: path_create doesnt work - 05/07/11 21:34

printf("%s",_chr(tpath));
Posted By: Bone

Re: path_create doesnt work - 05/08/11 20:08

Also empty
Posted By: jcl

Re: path_create doesnt work - 05/09/11 14:41

Quick user quiz: Which code experts can help Bone with his "empty" string?
Posted By: Quad

Re: path_create doesnt work - 05/09/11 14:48

STRING* tpath = str_create("tpath");

als0

STRING* tpath = str_create("#32"); means 32 chars of empty string.

Posted By: Uhrwerk

Re: path_create doesnt work - 05/09/11 20:31

That's exactly what it was supposed to do. Is there anything wrong with that?

From my point of view it should be:
Code:
printf("%s",tpath->chars);


I don't know what _chr exactly does, but as far as I know it is only supposed for the dll interface, isn't it?
Posted By: Bone

Re: path_create doesnt work - 05/10/11 09:15

Hm, the ways you show me dont work. I havent any idea.
I only want that the ENTITY moves along the path with ent_movepath()

Code:
path_set(ENTITY* entity,STRING* name)

A8.13 If an empty name string is given, the string is set to the path name the entity is currently attached to



I tried that with
Code:
STRING* tpath;
STRING* tpath = "#40";
STRING* tpath; = str_create("#40");



I dont want to read something, the function shall work.
The ent_movepath function need the name of a
path and I dont know that name because I use
path_create()

Please let me know how it works.
I have headache ...

Wish you a nice day
Posted By: Spirit

Re: path_create doesnt work - 05/10/11 16:29

Im not sure what your problem was, is it that you dont know how to create an empty string?

Strings are described in the manual. This is an empty string:

STRING* MyEmptyString = "";

or this

STRING* AnotherEmptyString = str_create("");

Hope this helps...

Posted By: Bone

Re: path_create doesnt work - 05/10/11 16:53

Both ways result in a crash in ent_movepath()
Posted By: Spirit

Re: path_create doesnt work - 05/12/11 11:53

Sure it crashes when you give an empty string instead of a path name.

I still don't understand what you want to do. Either you want to attach the entity to a new path, then you must give its name, or not, then you must give NULL. At least thats what the manual tells about ent_movepath.
Posted By: Bone

Re: path_create doesnt work - 05/12/11 13:35

I create a path with path_create.
After that i create a car and want the car move along
the path which i have created with path_create.
I have to use path_set with an empty string to get the pathname of the path.

Quote:
path_set(ENTITY* entity,STRING* name)
Attaches the given entity to the path with the given name. A8.13 If an empty name string is given, the string is set to the path name the entity is currently attached to. If NULL is given for the name, the entity is detached from its previous path.


I tried following
Code:
car = ent_create("mini.mdl",0,0);

	STRING* tpath ="";

// and = "#40" or = str_create("") or str_create("#40")

	

	path_set(road1.track_path,tpath);
 	ent_movepath(car,tpath, 5,2);
 	
 	ptr_remove(tpath);



It doesnt work.
road1.track_path is an ENTITY pointer to
an entity attached to the path created with path_create.
Posted By: Spirit

Re: path_create doesnt work - 05/12/11 14:31

Hmm I cant see how this is supposed to work. How can you name a path that you created with path_create? Created objects have no name, names are only for identifying objects that you placed in WED. Why don't you just create the path with the car?
Posted By: Bone

Re: path_create doesnt work - 05/12/11 15:49

http://manual.3dgamestudio.net/newfeatures8.htm

There you find
Quote:
Actor paths can be created by script with the path_create function. The path_set function can be used to retrieve the path name.


I think that should work for pathes created with path_create too.

I dont want to create the path for each vehicle that shall follow the street
Posted By: Spirit

Re: path_create doesnt work - 05/13/11 07:37

Well if something has no name, it would obviously not make much sense to search for it with a name command? When you only want to connect another entity to the same path, I think the entity path is stored in path_index so its just:

my.path_index = your.path_index;

Is this what you want to do?

© 2024 lite-C Forums