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
1 registered members (TipmyPip), 18,449 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
Move camera in the pan direction #389606
12/16/11 09:30
12/16/11 09:30
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, I'm trying to do a simple movement. "a" and "d" change the pan of my camera. Pressing "w" or "s" should move foreward and backwards in the direction the camera is looking.

How can I do this easily? Thanks for your help!

Re: Move camera in the pan direction [Re: PadMalcom] #389607
12/16/11 09:34
12/16/11 09:34

M
mercuryus
Unregistered
mercuryus
Unregistered
M



haha

move the camera with w/s or an entity?

Re: Move camera in the pan direction [Re: ] #389608
12/16/11 09:42
12/16/11 09:42
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Camera

Edit: Ah, and I want to avoid using c_move. A sin / cos approach would be nice laugh

Last edited by PadMalcom; 12/16/11 09:44.
Re: Move camera in the pan direction [Re: PadMalcom] #389610
12/16/11 09:55
12/16/11 09:55

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Code:
//rotate
vec_set(camera.pan, vector((camera.pan+(key_a-key_d)*time_frame*5)%360, 0,0));

// move
vec_set(camera.x, vector(camera.x+(key_w-key_s)*cosv(camera.pan)*time_frame*5, camera.y+(key_w-key_s)*sinv(camera.pan)*time_frame*5, 0));



Re: Move camera in the pan direction [Re: ] #389611
12/16/11 10:13
12/16/11 10:13
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
merci! laugh

Re: Move camera in the pan direction [Re: PadMalcom] #389613
12/16/11 10:54
12/16/11 10:54
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 can also achieve it without trigronometry

Code:
VECTOR vtemp;
...
vec_set ( vtemp, vector ( kwy_w - key_s, key_d - key_a, 0 );
vec_rotate ( vtemp, camera.pan );
vec_normalize ( vtemp, Speed * time_step );
vec_add ( camera.x, vtemp );



Salud!

Re: Move camera in the pan direction [Re: txesmi] #389660
12/16/11 16:53
12/16/11 16:53
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hey txesmi,

this does not work, the player is only going to the left and to the right but he does not turn.

Re: Move camera in the pan direction [Re: PadMalcom] #389753
12/17/11 22:31
12/17/11 22:31
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
blush sorry, i didn't read the topic properly...

big bloomer

Re: Move camera in the pan direction [Re: txesmi] #389803
12/18/11 18:19
12/18/11 18:19
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hehe no prob!

@mercuryus: How would I add straving in there?

EDIT: Figured it out:
Code:
// move
		vNewPosition = vector(
			camera.x+(key_w-key_s)*cosv(camera.pan)*time_step*WALK_SPEED  +(key_a-key_d)*cosv(camera.pan+90)*time_step*WALK_SPEED,
			camera.y+(key_w-key_s)*sinv(camera.pan)*time_step*WALK_SPEED  +(key_a-key_d)*sinv(camera.pan+90)*time_step*WALK_SPEED,
			0
		);
		
		
		vec_set(camera.x, vNewPosition);



Last edited by PadMalcom; 12/18/11 18:39.

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