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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Smart camera.pan changing #383682
09/23/11 18:02
09/23/11 18:02
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
Here's something I've been struggling with for some time. I've got a function that, when passed 5 args (x, y, z, pan, tilt) it smoothly moves the camera to that position. X, Y, Z and Tilt were easy, assuming you're never looking upside down. I did those by dividing the remaining distance to the goal by the original distance to the goal, multiplying by 180, and using the sin as a velocity factor in each cycle.

The hard part is doing something like this with the pan. The difficulty arises from the fact that 359 and 1 are actually closer than they would mathematically seem... I need it to detect which direction (left vs right) it should be turning based on how "far away" the final pan is from the current pan.

Any ideas would be GREATLY appreciated!


"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."
Re: Smart camera.pan changing [Re: gSet] #383683
09/23/11 18:08
09/23/11 18:08
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Simply use ang(camera.pan).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Smart camera.pan changing [Re: Superku] #383872
09/26/11 15:28
09/26/11 15:28
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
Awesome - this function is incredibly useful for this sort of thing! I had a big ugly pile of if statements to try to determine the direction that should be used, but they didn't even work properly.


"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."
Re: Smart camera.pan changing [Re: gSet] #383873
09/26/11 15:33
09/26/11 15:33
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
Hm.. Actually, it turns out I must have implemented this improperly. Are you able to give me an example of how this function should be used to shift the camera from its current pan to a given pan?


"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."
Re: Smart camera.pan changing [Re: gSet] #383874
09/26/11 15:43
09/26/11 15:43
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hm the function "ang()" simply returns the shifted camera angle, have you checked the manual already?

camera.pan = ang(camera.pan); //now camera.pan is between -180...180

You can use the following code to smoothly turn the camera to your target angle:
camera.pan += ang(target_pan - camera.pan)/2*time_step;


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Smart camera.pan changing [Re: Superku] #383876
09/26/11 15:53
09/26/11 15:53
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
Thanks - I had checked the manual, I just hadn't made the connection of how to use this shift to move the camera in the proper direction. This seems to work perfectly.


"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."

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