How make player go to the point you clicked with mouse?

Posted By: Eagelina

How make player go to the point you clicked with mouse? - 06/01/09 09:35

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?
Posted By: Spirit

Re: How make player go to the point you clicked with mouse? - 06/01/09 09:56

First find the target position of where you click with the mouse, for this use c_trace from mouse_pos3d in direction of mouse_dir3d.

Then get the vector from the player to the target position, and rotate the players pan angle toward that position, and let the player walk until the distance to the target position is below a minimum.

Thats the general idea.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/01/09 12:57

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?

Code:
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);
	}
}

Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/01/09 13:18

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?


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);
	}
}

Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/01/09 16:05

confused cry whistle crazy

Is there anyone that have some good suggestions? On how I can solve my problem?
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 10:42

?
Posted By: Anonymous

Re: How make player go to the point you clicked with mouse? - 06/02/09 10:52

Mouse_map:

BMAP* myMouse = "maus.bmp"; // or better 32bit TGA

...

mouse_map=myMouse;

------------------------------------------------
Walk to mouse-klick-pos: 2D or 3D?
Posted By: KiwiBoy

Re: How make player go to the point you clicked with mouse? - 06/02/09 10:54

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 smile

**...and try swapping ignore passable with glide smile
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 10:57

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.....
Posted By: KiwiBoy

Re: How make player go to the point you clicked with mouse? - 06/02/09 10:59

Thats what I was suggesting regarding Georges article, each node was individually placed by a click action.
As for your move, I replied by edit earlier.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 11:01


@mercuryus

the Walk to mouse is 3D. I get the player to move 1 time to the mouse, but when I click one more time to move it somewhere else, the player just turns and stay still......

I know it is something very easy to solve this, but I cant see it....... it is so frustrating.... blush
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 11:07

tried to swap ignor passable with glide, but no change.... goes one time to the point I clicked and when I click somehwere else..... player just turns and stay still.... as I was writing to mercuryus , the answer is staring right in my face..... I know it, but I cant see it..... it is always an easy solution..... wink
Posted By: KiwiBoy

Re: How make player go to the point you clicked with mouse? - 06/02/09 11:12

AUM 80 Q and A for the article mentioned.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 11:12

@KiwiBoy :

Found the code that George wrote. It is in Aum 34. I am going to study it....
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 11:13

ok going to look at that too
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 17:17

How do I "translate" this to Lite-C ?

trace_mode = ignore_you + ignore_passable + use_box;
Posted By: Stromausfall

Re: How make player go to the point you clicked with mouse? - 06/02/09 17:32

in lite-c u add the "trace_mode" to the trace command itself (look for c_trace in the "online manual")

c_trace(startPos,endPos,IGNORE_YOU|IGNORE_PASSABLE|USE_BOX);

cheers
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/02/09 17:34

Thanks! I am learning fast here..... grin
Posted By: testDummy

Re: How make player go to the point you clicked with mouse? - 06/02/09 19:02

Simply forgot to reset variabel_1?
Not responsible for flaws / errors in code.
Code is "sample" only.
Code:
VECTOR* pl_vDest = { x=0; y=0; z=0; } // player dest VECTOR
var pl_bDest = 0;  // player dest VECTOR set (boolean)?
action player_mouseAct(){
	c_setminmax(me);
	VECTOR temp; vec_zero(temp);
	while(1){
		if(mouse_left==1){
			pl_bDest = 1;		// dest set
			vec_set(pl_vDest, mouse_pos3d.x);
		}
		if (pl_bDest) {
			vec_diff(temp, pl_vDest, my.x);
			vec_to_angle(temp, temp);
			temp.pan = ang(temp.pan - my.pan);
			temp.pan = min(abs(temp.pan), 5 * time_step) * sign(temp.pan);
			temp.tilt = 0;
			temp.roll = 0;
			c_rotate(me, temp, IGNORE_PASSABLE);
			if(vec_dist(my.x, pl_vDest) > (my.max_x * 1.75)) {
				c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|GLIDE|IGNORE_PASSABLE);
			}
		}
		wait(1);
	}
}

Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 08:28

I did look and tried yours, like it, but cant make it work as I whant to. Thanks for the suggestion.
And yes I have to reset the variabel_1. But when I do that the player never stops....
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 08:36

The progress is going forward grin
I have now a code that works almost as it is supposed to. I whant a simple code to use so I can understand what I am doing..... smile....

QUESTION:
How or where in my code can I reset variabel_1 to 0 again. I have tried several places. And ended up with a if else.
So how do I write the else part so the player stops when it reaches the point I have clicked? When I use the code without the else, it goes to that point and stops. But dont react when I click again. So I must reset the varabel_1. Anyone of you have any suggestion on how to do that so it works?Then I will be gratefull!!!
And yes I can see that my code isent the best....but it works....

Code so far is this for the
mouse:
Code:
VECTOR temp;
vec_zero(temp);

function point_mouse()
{

  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);
  	}
}


player:
Code:
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_pos3d.x);//mouse_pos
			vec_sub(temp,my.x);
			vec_to_angle(my_angle,temp);
			my.pan = my_angle.pan;
			vec_set(temp,mouse_pos3d.x);
			temp.z = my.z;
		}
		if(variabel_1 == 0)
		{
			if(vec_dist(my.x,temp)<=0.5) 
			{
			variabel_1 = 1;
			}
			c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
			
	
		}
	else
//		{
//			variabel_1 = 0;//setting the variable to null?
//		}
			
		wait(1);
	}
	
}







Posted By: testDummy

Re: How make player go to the point you clicked with mouse? - 06/03/09 08:44

Code:
action player_mouseAct(){
	c_setminmax(me);
	var variabel_1 = 0;
	
	VECTOR temp; vec_zero(temp);
	ANGLE my_angle; vec_zero(my_angle);
	while(1){
		
		if(mouse_left==1){
			variabel_1 = 1;
			vec_set(temp,mouse_pos3d.x);//mouse_pos
			vec_sub(temp,my.x);
			vec_to_angle(my_angle,temp);
			my.pan = my_angle.pan;
			vec_set(temp,mouse_pos3d.x);
			temp.z = my.z;
		}
		if(variabel_1 == 1) {
			if(vec_dist(my.x,temp)<=0.5) {
				variabel_1 = 0;
			} else {
				c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
			}
		}		
		wait(1);
	}
	
}

Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 08:50

Nope dosent solve my problem. When I set the variabel_1 to the changes where you suggested. The same problems occure....(I can change them as yu did and then it starts to move by it self, and then stops and never moves again)
And when I change this part :
Code:
if(variabel_1 ==0)//deff 0
		{
			if(vec_dist(my.x,temp)<=0.5) 
			{
			variabel_1 = 1;//def 1
			}
			c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
			
	
		}

Setting Variabel_1 = 0 ;
The player never stops, just "running" around until you click somewhere else...then it goes to that part and keeps "running" never stops. So I must have some kind of "stopping" part.....

And I think I must have it in a else part or something like that..... But my brain cant see straight.....smile
Posted By: testDummy

Re: How make player go to the point you clicked with mouse? - 06/03/09 08:55

That might be because, it can never get within 0.5 quants of the target position? 'You' might try to increase the hit threshold distance to something larger, like (my.max_x + my.max_z) * 1.2, but that might be not large enough, or too large.?
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 09:05

Tried that one, like this

if(vec_dist(my.x,temp)<=(my.max_x + my.max_z) * 1.2) //def 1

But it isent there the problem is . Because when I set it like this:

Code:
		if(variabel_1 ==0)//deff 0
		{
			if(vec_dist(my.x,temp)<=1) //def 1
			{
			variabel_1 = 1;//def 1
			}
			c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
			
	
		}


It does what it is supposed to: Go to where I clicked with the mouse. It does that, and stops at it is supposed to. But when I whant the player to go to the next point, the player turns toward the place I pointed but dosent move..... So it gets to the "turning" code....but not loonger....

So I think I must have some kind of test , to see if the variabel_1 is changed and when I click again, it shall al start over...... like return or something like that we use in other programming languages.
Posted By: KiwiBoy

Re: How make player go to the point you clicked with mouse? - 06/03/09 09:24

woops, already solved by testDummy...
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 11:02

@KiwiBoy :

No it isent solved yet.....
Still dont get the code to do what I whant.....

I whant to be able to move the player several times , not only one time. ......
Posted By: KiwiBoy

Re: How make player go to the point you clicked with mouse? - 06/03/09 11:30

Hi,

Untested but should show a clear way out smile

Code:
action player_mouseAct()
{
	wait(1);
	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;//unset on mouse click
			vec_set(temp,mouse_pos3d.x);//mouse_pos
			vec_sub(temp,my.x);
			vec_to_angle(my_angle,temp);
			my.pan = my_angle.pan;
			vec_set(temp,mouse_pos3d.x);
			temp.z = my.z;
		}
		
		
	if(variabel_1 !=1){wait(1);}
//alternatly; if((variabel_1 !=1) && (vec_dist(my.x,temp) > 0.5)){wait(1);}		
		
			if(vec_dist(my.x,temp)<=0.5) 
			{
			variabel_1 = 1;//set on trigger range
			c_move(me,vector(10*time_step,0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);
			}
		

			
		wait(1);
	}
	
} 


Hope it helps...
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 13:28

No! that didnt do the trick either..... Sounding like a spoiled brat that dont get what she whants..... cry smile....sorry....
I like all input you all contributes with..... Thanks you so much!

the original code works fine, only problem is that it only work one time.....
I need it to work everytime I click somewhere I whant the player go.....
Posted By: MrGuest

Re: How make player go to the point you clicked with mouse? - 06/03/09 13:54

heya, try
Code:
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);
			
		}
	}
}

Hope this helps
*untested*
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 14:04

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 grin
Posted By: MrGuest

Re: How make player go to the point you clicked with mouse? - 06/03/09 14:09

missed the wait(1); grin

Code:
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
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 14:21

No, sorry this dont work either. The player dosent move at all.... No reaction.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 14:24

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?

Posted By: croman

Re: How make player go to the point you clicked with mouse? - 06/03/09 14:59

what is your latest code? post it.
Posted By: Pappenheimer

Re: How make player go to the point you clicked with mouse? - 06/03/09 15:03

I would simply let the player walk when he isn't close to the clicked mouse position, then he automatically stops when he is close to that position.
When you click outside the players range, then the player automatically will walk to that new position.
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.
Posted By: croman

Re: How make player go to the point you clicked with mouse? - 06/03/09 15:38

here you go, it's working for me:

Code:
#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.html

try this with your level, with wmb file...
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 16:51

@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.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 17:00

Originally Posted By: Pappenheimer

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?
Posted By: Pappenheimer

Re: How make player go to the point you clicked with mouse? - 06/03/09 18:02

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.
Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/03/09 18:51

Originally Posted By: Pappenheimer
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!
Posted By: croman

Re: How make player go to the point you clicked with mouse? - 06/03/09 20:14

put origin of your character under its feets and try using blocks instead of models for level geometry
Posted By: Gumby22don

Re: How make player go to the point you clicked with mouse? - 06/04/09 07:31

the other thing you can do to not overstep the mark you are moving towards is:

c_move(me,vector(minv(7*time_step,vec_dist(my.x,temp2)),0,0),nullvector,IGNORE_ME|IGNORE_PASSABLE|GLIDE);

It should then move 7*time_step, or the remaining distance, whichever is smaller.

Don
have a great day
Posted By: Anonymous

Re: How make player go to the point you clicked with mouse? - 06/04/09 08:43

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

Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/05/09 07:41

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.
Code:
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);
	}
}

Posted By: Anonymous

Re: How make player go to the point you clicked with mouse? - 06/05/09 09:03

click on the image to download a demo (zip,2.4MB).
The model "kaiden2" is free from DevoN (thanx a lot).


Posted By: Eagelina

Re: How make player go to the point you clicked with mouse? - 06/05/09 09:15


@mercuryus
Wow Thanks ! Love it grin wink

The demo is great. I will now study the code and try to learn from it.

Thank you.
© 2024 lite-C Forums