Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,253 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 5 1 2 3 4 5
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 Offline OP
Senior Member
Eagelina  Offline 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 grin


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: MrGuest] #269562
06/03/09 14:09
06/03/09 14:09
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
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

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 Offline OP
Senior Member
Eagelina  Offline 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. smile
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 Offline OP
Senior Member
Eagelina  Offline 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. smile
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 Offline
Serious User
croman  Offline
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: Eagelina] #269576
06/03/09 15:03
06/03/09 15:03
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
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.

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 Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
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...

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

Joined: Mar 2006
Posts: 321
Norway
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?

Last edited by Eagelina; 06/03/09 17:02.

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] #269609
06/03/09 18:02
06/03/09 18:02
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
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.

Page 4 of 5 1 2 3 4 5

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

Gamestudio download | 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