Gamestudio Links
Zorro Links
Newest Posts
Missing PnL files in zOpen child processes
by DonQuijote. 10/19/26 11:11
ZorroGPT
by TipmyPip. 10/15/26 08:28
Alternative to Stooq for Zorro S
by Petra. 10/14/26 07:04
Stooq now requires an API key
by cwford. 10/08/26 23:27
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (DonQuijote, vince, AndrewAMD, ratz, Samed), 8,340 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 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 | 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