|
Re: How make player go to the point you clicked with mouse?
[Re: Pappenheimer]
#269613
06/03/09 18:51
06/03/09 18:51
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
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. Yes I had to change it to 250, then it worked. Thanks!
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]
#269626
06/03/09 20:14
06/03/09 20:14
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
put origin of your character under its feets and try using blocks instead of models for level geometry
Ubi bene, ibi Patria.
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Gumby22don]
#269700
06/04/09 08:43
06/04/09 08:43
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
It's not smart to use constants for the check if the player reached his destination (because the distance can vary of many reasons).
If you define that the player reached his destination when he get as closest as possible then the logic becomes easy:
1. store the distance to the destination before you move; 2. move; 3. check if the player got nearer to the destination - if not he has reached it; 4. (opt) place the player exacly on the destination
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: Eagelina]
#269907
06/05/09 07:41
06/05/09 07:41
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
THANK YOU TO YOU ALL FOR YOUR HELP!!Here are the code so far. It is working fine, point somewhere on the "floor" /"ground" and player moves there.BMAP* arrow = "cursor.tga";
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,IGNORE_ME);
if(hit.x != NULL)
{
vec_set(temp.x,hit.x);
}
}
function move_mouse();
function playerAct();
function main()
{
video_mode = 8;
video_screen = 2;
level_load("test2.WMB");
wait(2);
mouse_mode = 1;
mouse_map = arrow;
move_mouse();
}
function move_mouse()
{
while(1){vec_set(mouse_pos,mouse_cursor); wait(1);}
}
var walk_prosent;
var stand_prosent;
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)>=250) //>=40
{
c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
ent_animate(me,"walk",walk_prosent,ANM_CYCLE);
walk_prosent += 6 * time_step;
}
else{
ent_animate(my, "stand", stand_prosent, ANM_CYCLE); // then play its "stand" animation
stand_prosent += 5 * time_step;
}
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: ]
#269925
06/05/09 09:03
06/05/09 09:03
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
click on the image to download a demo (zip,2.4MB). The model "kaiden2" is free from DevoN (thanx a lot). 
|
|
|
Re: How make player go to the point you clicked with mouse?
[Re: ]
#269929
06/05/09 09:15
06/05/09 09:15
|
Joined: Mar 2006
Posts: 321 Norway
Eagelina
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2006
Posts: 321
Norway
|
@mercuryus Wow Thanks ! Love it  The demo is great. I will now study the code and try to learn from it. Thank you.
A6 and A7 Commercial ------------------- Programmer always searching for more to learn and understand.
|
|
|
|