Gamestudio Links
Zorro Links
Newest Posts
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
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Top down shooter camera follow cursor #447850
01/09/15 06:45
01/09/15 06:45
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Hi,

I'm facing a problem that I can't seem to solve. I want the camera to follow the mouse cursor, but the player character to remain visible. So the camera can't go a certain distance away from the player.

like in this game -->game

anyone can help whit this plz?

Re: Top down shooter camera follow cursor [Re: Altarius] #447859
01/09/15 11:17
01/09/15 11:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
search in my older topics (which were created by me), there I was asking for the same thing, idea how to keep camera between player and mouse cursor.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Top down shooter camera follow cursor [Re: Altarius] #447860
01/09/15 12:16
01/09/15 12:16
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
you will need to substract the screen center to the mouse position, scale the resulting vector to your taste and place the camera in the point resulting from the sum of the player position and said vector.

Code:
camera->pan = 0;
camera->tilt = -90;
camera->roll = -90;
...
vecMouse.x = mouse_pos.x - ( screen_size.x / 2 );
vecMouse.y = ( screen_size.y / 2 ) - mouse_pos.y;
vecCameraOffset.x = player.x + vecMouse.x*0.8;
vecCameraOffset.y = player.y + vecMouse.y*0.8;
camera.x += (vecCameraOffset.x-camera.x) * time_step * 0.1;
camera.y += (vecCameraOffset.y-camera.y) * time_step * 0.1;



Salud!

Re: Top down shooter camera follow cursor [Re: Altarius] #447863
01/09/15 16:06
01/09/15 16:06
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Thx a lot guys.

Work like a charm =)

Re: Top down shooter camera follow cursor [Re: Altarius] #447871
01/10/15 11:44
01/10/15 11:44
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Happy to help!


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