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
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 13,972 guests, and 6 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 1 of 2 1 2
problem with mouse_pos3d #367939
04/20/11 08:10
04/20/11 08:10
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Hi guys,
Here's my problem:
I'm still writing a small strategie game. Now youre supposed to be able to send the unit somewhere by clicking on a spot on the map. So I need the world positions of the mouse. Theres something about mouse_pos3d in the manual, but I don't really get it to work.
Code:
VECTOR pos;
if (mouse_right)
{
vec_set(pos,mouse_pos3d);
}


thanks already

Re: problem with mouse_pos3d [Re: Wollez] #367942
04/20/11 09:16
04/20/11 09:16
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
try this one
Code:
// Mausposition im 3D Level
function mouse3d()
{
	VECTOR mouse3d_pos;
	vec_set(mouse3d_pos,mouse_dir3d);
	vec_normalize(mouse3d_pos,20000);
	vec_add(mouse3d_pos,camera.x);
	
	c_trace(camera.x,mouse3d_pos, IGNORE_MODELS);
}




my webside : www.ascalon.jimdo.de
Re: problem with mouse_pos3d [Re: Ascalon] #367946
04/20/11 09:52
04/20/11 09:52
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
thanks for the quick answer.
but if I create a model at the target position (where c_trace hits ground) it's pretty far of from where I clicked.
Does someone know why??

Re: problem with mouse_pos3d [Re: Wollez] #367949
04/20/11 10:23
04/20/11 10:23
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

Have you already set mouse_mode to 4?

Code:
mouse_mode = 4;



Re: problem with mouse_pos3d [Re: 3dgs_snake] #367955
04/20/11 10:56
04/20/11 10:56
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Yeah, mouse_mode was already on 4, but the problem is, that the coordinates simply are wrong, if I crate a model there, it's not there where I clicked

Re: problem with mouse_pos3d [Re: Wollez] #367960
04/20/11 11:10
04/20/11 11:10
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
how do you use the target position on your model ? can you show this please ?

do you use c-script or lite-c ?

Last edited by Ascalon; 04/20/11 11:24.

my webside : www.ascalon.jimdo.de
Re: problem with mouse_pos3d [Re: Ascalon] #367968
04/20/11 12:12
04/20/11 12:12
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
If you want to, I can make simple demo for you (LITE-C) PM me if needed.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: problem with mouse_pos3d [Re: Ascalon] #367987
04/20/11 13:14
04/20/11 13:14
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline OP
Newbie
Wollez  Offline OP
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Code:
if (mouse_right) 
{
   vec_set (mouse_click, mouse_dir3d); 
   vec_normalize(mouse_click, 4000); 
   vec_add (mouse_click, mouse_pos3d); 		
   c_trace (camera.x, mouse_click, IGNORE_MODELS); 
   vec_set( mouse_click, target );
   ent_create ("position1.mdl", target.x, NULL);
}


I use Lite-c

Re: problem with mouse_pos3d [Re: Wollez] #367994
04/20/11 14:18
04/20/11 14:18
Joined: Apr 2005
Posts: 274
austria
Ascalon Offline
Member
Ascalon  Offline
Member

Joined: Apr 2005
Posts: 274
austria
change your
Code:
ent_create("position1.mdl",target.x,NULL);

to this
Code:
ent_create("position1.mdl",mouse_click.x,NULL);




my webside : www.ascalon.jimdo.de
Re: problem with mouse_pos3d [Re: Wollez] #368012
04/20/11 16:45
04/20/11 16:45
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Code:
VECTOR mouse_click;
if (mouse_right) 
{
   vec_set (mouse_click, mouse_dir3d); 
   vec_normalize(mouse_click, 4000); 
   vec_add (mouse_click, mouse_pos3d); 		
   if (c_trace(camera.x, mouse_click, IGNORE_MODELS))
      ent_create ("position1.mdl",&hit->x, NULL);
}




Always learn from history, to be sure you make the same mistakes again...
Page 1 of 2 1 2

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