|
Re: How make player go to the point you clicked with mouse?
[Re: MrGuest]
#269558
06/03/09 14:04
06/03/09 14:04
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
Tried that one to, but I cant see anything when it starts. It is only giving me a "black" window. And everthing freezes.... So I dont know if it works. Even tried to set if(mouse_left==1) But still black screen. Thanks for trying 
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: MrGuest]
#269562
06/03/09 14:09
06/03/09 14:09
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
missed the wait(1);  action player_mouseAct(){
VECTOR vec_temp; vec_zero(vec_temp);
c_setminmax(me);
while(me){
if(mouse_left){
vec_set(vec_temp, mouse_pos3d.x); //mouse_pos
vec_sub(vec_temp, my.x);
vec_to_angle(my.pan, vec_temp);
vec_set(vec_temp, mouse_pos3d.x);
vec_temp.z = my.z;
}
if(vec_dist(my.x, vec_temp) <= 0.5){
c_move(me, vector(10*time_step, 0, 0), nullvector, IGNORE_ME | IGNORE_PASSABLE | GLIDE);
}
wait(1);
}
} Hope this helps
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: MrGuest]
#269566
06/03/09 14:21
06/03/09 14:21
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
No, sorry this dont work either. The player dosent move at all.... No reaction.
Last edited by Eagelina; 06/03/09 14:22.
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]
#269568
06/03/09 14:24
06/03/09 14:24
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
This is what I whant:
1 click mouse on the floor 2 player walkt to the clicked point 3 player stops at the clicked point 4 click new spot on the floor 5 player goes there
My original code does that, but only goes to nr 3 and stops there.... any suggestion on how I can make my code work?
Last edited by Eagelina; 06/03/09 14:26.
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]
#269574
06/03/09 14:59
06/03/09 14:59
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
what is your latest code? post it.
Ubi bene, ibi Patria.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Pappenheimer]
#269584
06/03/09 15:38
06/03/09 15:38
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
here you go, it's working for me:
#include <acknex.h>
#include <default.c>
function playerAct();
function point_mouse();
function move_mouse();
BMAP* arrow = "arrow.bmp";
function main()
{
video_mode = 8;
video_screen = 2;
level_load("test.mdl");
ent_create("soldier.mdl", nullvector, playerAct);
wait(3);
mouse_mode = 1;
mouse_map = arrow;
move_mouse();
}
function move_mouse()
{
while(1){vec_set(mouse_pos,mouse_cursor); wait(1);}
}
VECTOR temp;
function point_mouse()
{
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 5000;
vec_for_screen(temp,camera);
c_trace(camera.x,temp.x,IGNORE_ME);
if(hit.x != NULL)
vec_set(temp.x,hit.x);
//wait(1);
}
function playerAct()
{
camera.z += 200;
camera.tilt -= 35;
c_setminmax(me);
VECTOR temp2; vec_zero(temp2);
ANGLE my_angle; vec_zero(my_angle);
while(1){
point_mouse();
if(mouse_left==1){
while(mouse_left){wait(1);}
vec_set(temp2,temp.x);
vec_sub(temp2,my.x);
vec_to_angle(my.pan,temp2); // now MY looks at YOU
my.tilt = 0;
temp2.z = my.z;
}
if(vec_dist(my.x,temp2)>=40)
{
c_move(me,vector(7*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
}
// else{
// play stand animation here or something like that
// }
wait(1);
}
}
here's the link for that whole project, if you need it... http://rapidshare.com/files/240397679/Eagelina.rar.htmltry this with your level, with wmb file...
Last edited by cerberi_croman; 06/03/09 15:38.
Ubi bene, ibi Patria.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: croman]
#269590
06/03/09 16:51
06/03/09 16:51
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
@cerberi_croman Thanks a lot !!! Yepp!! This was what I trying to do. The code does finally what I whant.
But.... always a but...
How do I change or add to the code: so the player stops close to the point I have clicked? It still kind of "floats" of past the point I click.
Last edited by Eagelina; 06/03/09 16:55.
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: Pappenheimer]
#269595
06/03/09 17:00
06/03/09 17:00
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
No need of any variable, simply setting the vector of the position by mouse click and the players distance are needed to determine whether he walks or not.
@Pappenheimer And how would you do this that you have wroted here that I have quoted. Can you give me an example code , please?
Last edited by Eagelina; 06/03/09 17:02.
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]
#269609
06/03/09 18:02
06/03/09 18:02
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
The following part from cerberi_croman's code should already stop the player from 'floating' beyond the point you clicked:
if(vec_dist(my.x,temp2)>=40) { c_move(me,vector(7*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE); }
This means, the player only moves as long he isn't closer than 40 quants - that's a reasonable distance for the size of normal models - maybe the size of your model is much bigger. Play with the value, make it larger, 100 or 400, just to get an idea when the player stops walking.
|
|
|
|