Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, henrybane, AndrewAMD), 1,343 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Face the mouse pointer #335029
07/26/10 12:56
07/26/10 12:56
Joined: Jan 2009
Posts: 57
Slovakia
wolodo87 Offline OP
Junior Member
wolodo87  Offline OP
Junior Member

Joined: Jan 2009
Posts: 57
Slovakia
Hello,
I would like to make entity rotate to the mouse cursor in 2 axes (x,y, thats pan, I think) using top down camera. This could be used for example for shooting.
In the picture the teapot is always in the middle of the screen (with 500px y-offset). With mouse click, entity should be created at the position of the teapot and fly towards the mouse pointer.


I have figured out one solution using just mathematic functions, but it is quite ugly code. Is there any game studio function to achieve this?
Thanks in advance.

Last edited by wolodo87; 07/26/10 12:57.
Re: Face the mouse pointer [Re: wolodo87] #335178
07/27/10 06:50
07/27/10 06:50
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline
User
JoGa  Offline
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
I have something like this in my game:
Code:
vec_set(temp.x,vector(mouse_pos.x,mouse_pos.y,camera_dist));
		vec_for_screen(temp,camera);
		temp.z = 0;
		vec_sub (temp.x, you.x);
		vec_to_angle (my.pan, temp); // rotate it towards the target


camera_dist is the distance from the player to the camera, in my game: var camera_dist = 700;


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