0 registered members (),
1,119
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How make player go to the point you clicked with mouse?
#268990
06/01/09 09:35
06/01/09 09:35
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
I have been searching and trying out a lot of codes latey. But nothing does whant I whant it to. So maybee anyone of you can help me out here? I am looking for a smal but effective code that does this: Use the mouse , click on the ground and the player walks to that point. Click at a new place and the player walks to that point only using the "arrow" on the mouse.... and so on and so on. So how does this kind of code looks like?
Last edited by Eagelina; 06/01/09 09:49.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Spirit]
#269039
06/01/09 12:57
06/01/09 12:57
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
Well here are my trying code so far. Piced it together by looking and studying other type of code. My problem is now: The player moves towards the place I clicked with the mouse, but it dont stop there. How do I make the player stop at the point I click with the mouse?VECTOR temp;
function point_mouse()
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 200;
vec_for_screen(temp,camera);
c_trace(camera.x,temp,IGNORE_ME);
if(hit.x != NULL)
vec_set(my.x,hit.x);
wait(1);
}
action player_mouseAct(){
c_setminmax(me);
var variabel_1 = 1;
VECTOR temp; vec_zero(temp);
ANGLE my_angle; vec_zero(my_angle);
while(1){
if(mouse_left==1){
variabel_1 = 0;
vec_set(temp,mouse_pos.x);
vec_sub(temp,my.x);
vec_to_angle(my_angle,temp);
my.pan = my_angle.pan;
vec_set(temp,mouse_pos.x);
temp.z = my.z;
}
if(variabel_1 == 0){
if(vec_dist(my.x,temp)<=1)
variabel_1 = 1;
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|GLIDE|IGNORE_PASSABLE);
}
wait(1);
}
}
Last edited by Eagelina; 06/01/09 13:07.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269047
06/01/09 13:18
06/01/09 13:18
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
I have done some more changes in the code now: I can now make it stop near the place the mouse clicks. But I cant get it to move several times. When I try to click more times , the player only turns but dont moves. How to make the player moves everytime I click somewhere with the mouse? And how can I add the mouse_map to my code?VECTOR temp;
vec_zero(temp);
function point_mouse()
{
mouse_mode = 2;
//mouse_map = arrow;
while(1)
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 1000;
vec_for_screen(temp,camera);
c_trace(camera.x,temp,IGNORE_ME);
if(hit.x != NULL)
vec_set(my.x,hit.x);
wait(1);
}
}
action player_mouseAct(){
c_setminmax(me);
var variabel_1 = 1;
VECTOR temp; vec_zero(temp);
ANGLE my_angle; vec_zero(my_angle);
while(1){
if(mouse_left==1){
variabel_1 = 0;
vec_set(temp,mouse_pos.x);
vec_sub(temp,my.x);
vec_to_angle(my_angle,temp);
my.pan = my_angle.pan;
vec_set(temp,mouse_pos.x);
temp.z = my.z;
}
if(variabel_1 == 0){
if(vec_dist(my.x,temp)<=1)
variabel_1 = 1;
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|GLIDE|IGNORE_PASSABLE);
}
wait(1);
}
}
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269081
06/01/09 16:05
06/01/09 16:05
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
Last edited by Eagelina; 06/02/09 10:15.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269223
06/02/09 10:42
06/02/09 10:42
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269227
06/02/09 10:52
06/02/09 10:52
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
Mouse_map:
BMAP* myMouse = "maus.bmp"; // or better 32bit TGA
...
mouse_map=myMouse;
------------------------------------------------ Walk to mouse-klick-pos: 2D or 3D?
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269229
06/02/09 10:54
06/02/09 10:54
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
Member
|
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
Use the example code with the model 'potion bottle' as its reference but make it (the model) invisible. I remeber Geoge wote a script in Q&A but cant remeber which one, am currently researching... It concerned clicking a model path system and the player or NPC moving to each created model node then on to the next after some time there. Might help **...and try swapping ignore passable with glide
Last edited by KiwiBoy; 06/02/09 10:58.
Use the 'manual' Luke, the manual is your friend. 'Self reminder' My WebPage
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: KiwiBoy]
#269231
06/02/09 10:57
06/02/09 10:57
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
sounds intersting KiwiBoy, but I dont whant to have a predefined path. I whant to be able to click where ever I whant and the player goes there.....
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
|