|
|
weird function error
#240718
12/12/08 02:41
12/12/08 02:41
|
Joined: Dec 2008
Posts: 528 Wagga, Australia
the_mehmaster
OP
User
|
OP
User
Joined: Dec 2008
Posts: 528
Wagga, Australia
|
just a quick question. when i run the following function:
[code] function movechar() { if(player != NULL) { posidon.x = mouse_pos.x; posidon.y = mouse_pos.y; posidon.z = 0; vec_for_screen(posidon,camera); posidon.x += camera.x; posidon.y += camera.y; vec_set(player,posidon); } } [code\]
quick description: (posidon vector has been predefined) if the player pointer has been set to an entity, it sets the mouse coordinates to the posidon vector. it then turns this into world coordinates and adds the camera position. it then moves the player to this position, e.g (this function is triggered by a mouse click) you click somewhere, and the player goes there note that the camera is already looking down the z axis.
now, the problem is that when the containing script compiles, i get the error "'x': is not a member of 'function'" on the first posidon line. i have no idea what this means, as posidon is a variable, not a function. the definition of posidon follows: var posidon = vector(0,0,0);
any help is greatly appreciated,
|
|
|
Re: weird function error
[Re: the_mehmaster]
#240782
12/12/08 14:57
12/12/08 14:57
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Your function code should be using posidon[0], posidon[1], and posidon[2] instead of posidon.x, .y, and .z Unless you replace its global definition as VECTOR* posidon = { x=0, y=0; z=0; } instead of var posidon = vector(0,0,0); Using the var version may cause odd problems later if you use the vector(x,y,z) function too often.
Using the VECTOR* posidon = { x=0, y=0; z=0; } and leave the rest of your code as is would be my preferred option.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|