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, TipmyPip, OptimusPrime), 15,359 guests, and 7 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
3rd person camera #167792
11/16/07 19:01
11/16/07 19:01
Joined: Nov 2007
Posts: 14
F
FiskFisk33 Offline OP
Newbie
FiskFisk33  Offline OP
Newbie
F

Joined: Nov 2007
Posts: 14
how do i change the cameras position relative to an entity?
ive searched around and cant find any way to do it

or isnt that the "right" way to make 3rd person view?

Last edited by FiskFisk33; 11/16/07 19:23.
Re: 3rd person camera [Re: FiskFisk33] #167793
11/16/07 21:55
11/16/07 21:55
Joined: Oct 2006
Posts: 106
i_program_games Offline
Member
i_program_games  Offline
Member

Joined: Oct 2006
Posts: 106
Here is a simple pseudocode example. In other words the general logic is correct but you may not be able to directly copy/paste to test it.

while(my.x)
{
camera.x=my.x;
wait(1);
}

Of course you'll want to offset the position of the camera as well as it's tilt to get the angle and distance you want.

Re: 3rd person camera [Re: i_program_games] #167794
11/16/07 23:09
11/16/07 23:09
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
erm..., well a little more math is needed than that, but yeah thats nice for a start to learn scripting. It's not psuedo code though, psuedo code is more in a written style:

psuedo code:
Code:

while (player exists) {
set camera [distance] behind player;
wait(1);
}



now for answering the question, this has been asked alot by beginners, and I remember me quite a few times giving an answer. Just perform a search on this forum about "relative rotation".

Anyway, I shall spare you the search this time and give you the answer:

Code:

...
while (player) { //we dont want empty pointers when the player is gone

//lets place the camera behind the player
vec_for_angle (camera.x, player.pan); //returns a direction vector (values will vary from -1 to 1)
vec_normalize (camera.x, distance); //now we stretch the camera backwards (assuming distance = -500;)
vec_add (camera.x, player.x); //now add to player position so we are behind it
camera.z = player.z + 800; //and we pretend to be a bird, high in the sky

//facing camera to player
vec_set (temp.x, player.x);
vec_sub (temp.x, camera.x); //substract camera position from player, so we have a player-facing direction vector
vec_to_angle (camera.pan, temp.x); //calculate the angle from the direction vector and let the camera face the player

wait(1);
}
...



Last edited by Joozey; 11/16/07 23:09.

Click and join the 3dgs irc community!
Room: #3dgs
Re: 3rd person camera [Re: Joozey] #167795
11/17/07 09:10
11/17/07 09:10
Joined: Nov 2007
Posts: 14
F
FiskFisk33 Offline OP
Newbie
FiskFisk33  Offline OP
Newbie
F

Joined: Nov 2007
Posts: 14
Whoa, those lines ar far above my level :O

Still, wirh some tweaking i got it to work just like i wanted to.
THANX!!!!


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