1 registered members (AndrewAMD),
873
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: 3D point and click pathfinding
[Re: tompo]
#123762
04/15/07 23:00
04/15/07 23:00
|
Joined: Jul 2006
Posts: 91 Florida, USA
Knuckles
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2006
Posts: 91
Florida, USA
|
Alright, I'm getting empty pointer errors from it. I commented out pointerMDL because it kept saying 'parameter unknown' even after I declared it above. Now it's saying that my.push = 50; is an empty pointer. This is what I declared above the action script: Code:
entity* heru; entity* npc1; entity* npc2; entity* npc3; entity* temp_npc; // entity* pointerMDL; (commented out from the error)
action heru_act {heru = me; heru = my;} action npc1_act {npc1 = me; npc1 = my;} action npc2_act {npc2 = me; npc2 = my;} action npc3_act {npc3 = me; npc3 = my;}
|
|
|
Re: 3D point and click pathfinding
[Re: Knuckles]
#123763
04/15/07 23:24
04/15/07 23:24
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
but tell me... what you want to do?! just a game with 3rd camera or isometric view where your player goes from his position to position where you click with mouse on the ground?
Last edited by tompo; 04/16/07 00:04.
Never say never.
|
|
|
Re: 3D point and click pathfinding
[Re: tompo]
#123764
04/16/07 00:03
04/16/07 00:03
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
if yes... try something like this: //not tested but should be fine Code:
entity* my_target; entity* player;
define speed, skill1; var distance[3]; var lets_move;
function put_target { my_target = me; my.passable =on; my.invisible =on; while(1) { MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y; temp.x = MOUSE_POS.x; temp.y = MOUSE_POS.y; temp.z = 100; vec_for_screen(temp,CAMERA); vec_set(my.x, temp); temp.z -= 1000; trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_SPRITES + ignore_models + use_box + scan_texture; result = trace (my.x, temp); my.z -= result; wait(1); } }
action player_action { player = me; my.narrow =on; you = ent_create("model.mdl",my.x,put_target); //f.e. small cube my.speed = 60; //change this to your world scale while(1) { distance = vec_dist(my.x,my_target.x); if(lets_move == 1) { vec_set(temp,my_target.x); vec_sub(temp,my.x); vec_to_angle(my.pan,temp); c_move(me,vector(my.speed *time_step *1,0,0),nullvector,GLIDE | ACTIVATE_TRIGGER | IGNORE_SPRITES | IGNORE_PASSENTS | use_box); if(distance <= 10){lets_move =0}; } my.tilt =0; wait(1); } }
function lets_go { lets_move = 1; }
on_mouse_left lets_go;
Last edited by tompo; 04/16/07 00:27.
Never say never.
|
|
|
Re: 3D point and click pathfinding
[Re: tompo]
#123765
04/16/07 00:06
04/16/07 00:06
|
Joined: Jul 2006
Posts: 91 Florida, USA
Knuckles
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2006
Posts: 91
Florida, USA
|
Quote:
but tell me... what you want to do?! just a game with 3rd camera or isometric view where your player goes from his position to position where you click with mouse on the ground?
yes, basically a standard 3D game that has point and click movement. It's not isometric, but you can move the camera around, but I want to work on this 1 step at a time first.
|
|
|
Re: 3D point and click pathfinding
[Re: Knuckles]
#123766
04/16/07 00:16
04/16/07 00:16
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
Try use this what i wrote above. If something is wrong... just write ![](/ubbthreads/images/graemlins/wink.gif) You have to add some kind of gravity to your model and of'course animations.
Last edited by tompo; 04/16/07 08:14.
Never say never.
|
|
|
Re: 3D point and click pathfinding
[Re: Knuckles]
#123768
04/16/07 16:14
04/16/07 16:14
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
Sorry that I have no time to check it out... but this one should be work Code:
var distance_to_target; var move_position[3]; //move vector var my_target[3]; //target vertor var vecTo[3]; var vecFrom[3]; var dest[3]; define _speed, skill1; define _moving, skill2;
IFNDEF MSG_DEFS; FONT digit_font,<digfont.pcx>,12,16; ENDIF; panel helper { digits = 20, 20, 3, digit_font, 1,player._moving; digits = 20, 40, 3, digit_font, 1,distance_to_target; flags REFRESH,visible; }
Function get_target() { while(mouse_left == 1) { MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y; vecFrom.X = MOUSE_POS.X; vecFrom.Y = MOUSE_POS.Y; vecFrom.Z = 1;// close point vec_set(vecTo,vecFrom); vec_for_screen(vecFrom,CAMERA); vecTo.Z = 10000; vec_for_screen(vecTo,CAMERA);// far point trace(vecFrom,vecTo);// trace a line between the two points vec_set(my_target,target); vec_set(move_position,target); vec_sub(move_position,player.x); vec_to_angle(player.pan,move_position); distance_to_target = vec_dist(player.x,my_target.x);//calculate distance player._moving = 1;//I have to move player.tilt = 0; wait(1); } }
function player_move() { while(1) { if(player._moving == 1) //if I have to move... { distance_to_target = vec_dist(player.x,my_target.x); if(distance_to_target > 45)//if target is far away... { vec_set(temp,my_target.x);// keep target vec_sub(temp,player.x); // check my position vec_to_angle(player.pan,temp);// turn to target my._speed = 10; } if(distance_to_target <= 45)//if target is close { player._moving = 0;//I have not to move anymore my._speed = 0; } } if(player._moving == 0) //if I have not to move... { my._speed = 0; wait(1);// do nothing. } my.tilt = 0;//stay straight vec_set(temp,my.X); temp.Z -= 1000; trace_mode=IGNORE_ME+IGNORE_MODELS+ignore_passable + USE_BOX; result = trace (my.x, temp); my.z -= result; //keep me on the ground c_move(me,vector(my._speed *time_step,0,0),nullvector,GLIDE | ACTIVATE_TRIGGER | IGNORE_SPRITES | IGNORE_PASSENTS | use_box); wait(1); } }
action my_player { player = me; MY.FAT = OFF; MY.NARROW = ON; mouse_range = 10000; player_move(); }
On_mouse_left get_target;
Last edited by tompo; 04/16/07 18:03.
Never say never.
|
|
|
|