Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TedMar), 1,031 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 5 1 2 3 4 5
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 Offline OP
Senior Member
Eagelina  Offline 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. smile
Re: How make player go to the point you clicked with mouse? [Re: Eagelina] #268993
06/01/09 09:56
06/01/09 09:56
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
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.

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 Offline OP
Senior Member
Eagelina  Offline 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?

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


Last edited by Eagelina; 06/01/09 13:07.

A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
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 Offline OP
Senior Member
Eagelina  Offline 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?


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. smile
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 Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
confused cry whistle crazy

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

Last edited by Eagelina; 06/02/09 10:15.

A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
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 Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
?


A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
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

M
mercuryus
Unregistered
mercuryus
Unregistered
M



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 Offline
Member
KiwiBoy  Offline
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 smile

**...and try swapping ignore passable with glide smile

Last edited by KiwiBoy; 06/02/09 10:58.

Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

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 Offline OP
Senior Member
Eagelina  Offline 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. smile
Re: How make player go to the point you clicked with mouse? [Re: Eagelina] #269232
06/02/09 10:59
06/02/09 10:59
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
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.


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Page 1 of 5 1 2 3 4 5

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1