3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Lite-C: Object following a path
#236173
11/12/08 15:02
11/12/08 15:02
|
Joined: Sep 2008
Posts: 9
Staakman
OP
Newbie
|
OP
Newbie
Joined: Sep 2008
Posts: 9
|
Hi,
I'm trying to let an object following a path with an action. I tryed using the patrol_path() action example. Problem I'm having is it dosn't recognize _FORCE and _MOVEMODE. What is the best solution for this when I'm programming in a .c file? Should I include some header?
Thanks in advance,
Staakman
/////////////////////////////////Start Code///////////////////////////////////// // move along a path loop // uses _FORCE, _MOVEMODE action patrol_path() { // attach entity to nearest path result = path_scan(me,my.x,my.pan,vector(360,180,1000)); if (result == 0) { return; } // no path found // find first waypoint var node = 1; // start at first node path_nodepos(my,node,my._TARGET_X); while (my._MOVEMODE) { // find direction result = vec_to_angle(angle,vec_diff(temp,my._TARGET_X,my.x)); // near target? Find next waypoint of the path if (result < 25) { node = path_nextnode(my,node,1); path_nodepos(my,node,my._TARGET_X); } // turn and walk towards target actor_turnto(angle.PAN); actor_moveahead(MY._FORCE); wait(1); } } /////////////////////////////////End Code/////////////////////////////////////
Last edited by Staakman; 11/12/08 15:03.
|
|
|
Re: Lite-C: Object following a path
[Re: Quad]
#236228
11/12/08 21:57
11/12/08 21:57
|
Joined: Sep 2008
Posts: 9
Staakman
OP
Newbie
|
OP
Newbie
Joined: Sep 2008
Posts: 9
|
Thanks.... that fixed several bugs next bugs are a bit harder: //path_nodepos(my,node,my._TARGET_X); // Changed to following code:
path_scannode(my, node); // Assume this is correct?
// and there is a bug with the following code
result = vec_to_angle(ANGLE * ang,vec_diff(temp,my._TARGET_X,my.x));
Last edited by Staakman; 11/12/08 22:00.
|
|
|
Re: Lite-C: Object following a path
[Re: Staakman]
#236243
11/13/08 00:16
11/13/08 00:16
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
#define skill22 _TARGET_X
vec_to_angle(ang,vec_diff(temp,my._TARGET_X,my.x));
3333333333
|
|
|
Re: Lite-C: Object following a path
[Re: Quad]
#236251
11/13/08 01:36
11/13/08 01:36
|
Joined: Oct 2008
Posts: 67
pewpew
Junior Member
|
Junior Member
Joined: Oct 2008
Posts: 67
|
i don't understand. why do you need to #define the skill20-22 things?
HURRR DERP DERP DEERRPP HURR
|
|
|
Re: Lite-C: Object following a path
[Re: pewpew]
#236252
11/13/08 02:36
11/13/08 02:36
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
it's just for giving names to skills, makes the code easire to read/write.
and comments like //uses:
makes skills show up in the behaviour panel of wed.
3333333333
|
|
|
Re: Lite-C: Object following a path
[Re: Quad]
#237131
11/18/08 14:33
11/18/08 14:33
|
Joined: Sep 2008
Posts: 9
Staakman
OP
Newbie
|
OP
Newbie
Joined: Sep 2008
Posts: 9
|
////////////////////////////////////////// Current Code: #define _FORCE skill18 // value = 1 #define _MOVEMODE skill19 // value = 1 #define _TARGET_X skill20 // value = 1
action patrol_path() { // attach entity to nearest path result = path_scan(me,me.x,me.pan,vector(360,180,1000)); if (result == 0) { return; } // no path found // find first waypoint var node = 1; // start at first node //path_nodepos(my,node,my._TARGET_X); path_scannode(my, node); while (my._MOVEMODE) { // find direction //result = vec_to_angle(ANGLE * ang,vec_diff(temp,my._TARGET_X,my.x)); result = vec_to_angle(ang,vec_diff(vector,my._TARGET_X,my.x)); // near target? Find next waypoint of the path if (result < 25) { node = path_nextnode(my,node,1); //path_nodepos(my,node,my._TARGET_X); path_scannode(my, node); } // turn and walk towards target //actor_turnto(angle.PAN); //actor_moveahead(MY._FORCE); wait(1); } } ////////////////////////////////////////// End of Code
The code does run but as soon as the game starts he says: Error (E1513) crash in patrol_path().
The code is pretty basic and I can't find anything wrong with. Anyone able to help me? Thanks in advance!
Last edited by Staakman; 11/18/08 14:36.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|