Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, 1 invisible), 885 guests, and 3 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
Page 1 of 2 1 2
smooth(camera.pan) #343349
10/05/10 18:56
10/05/10 18:56
Joined: Apr 2008
Posts: 650
Sajeth Offline OP
User
Sajeth  Offline OP
User

Joined: Apr 2008
Posts: 650
Hello folks,
how can I smooth a camera.pan value with the smooth function without getting those twists as soon as the value changes from -180 to 180 and vice versa? Tried different things, including a reset of the smooth function on each "big jump", but this has the side effects of causing camera "hickups".
Regards


Teleschrott-Fan.
Re: smooth(camera.pan) [Re: Sajeth] #343350
10/05/10 18:57
10/05/10 18:57
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
in which way do you control your camera.pan?


Visit my site: www.masterq32.de
Re: smooth(camera.pan) [Re: MasterQ32] #343351
10/05/10 18:59
10/05/10 18:59
Joined: Apr 2008
Posts: 650
Sajeth Offline OP
User
Sajeth  Offline OP
User

Joined: Apr 2008
Posts: 650
Always turned towards a specific actor, set by vec_to_angle
If theres no feasible way, I'll have to find a workaround...

Last edited by Sajeth; 10/05/10 19:00.

Teleschrott-Fan.
Re: smooth(camera.pan) [Re: Sajeth] #343353
10/05/10 19:05
10/05/10 19:05
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
camera.pan += ang(target_pan-camera.pan)*time_step;

Since I discovered this method I use it in every code to smooth positions and angles. If the camera turns to fast, use the following code:

camera.pan += clamp(ang(target_pan-camera.pan),-15,15)*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: smooth(camera.pan) [Re: Superku] #343355
10/05/10 19:34
10/05/10 19:34
Joined: Apr 2008
Posts: 650
Sajeth Offline OP
User
Sajeth  Offline OP
User

Joined: Apr 2008
Posts: 650
Code:
if(abs(camera.pan-oldcampan)>100)
	{
		if(camera.pan>oldcampan)
		oldcampan+=360;
		else
		oldcampan-=360;
	}
	camera.pan = camera.pan * (1-CAMERASMOOTHFAC) + oldcampan * CAMERASMOOTHFAC;
	oldcampan=camera.pan;



Probably the most dirty way to pull this off... grin But works just fine.


Teleschrott-Fan.
Re: smooth(camera.pan) [Re: Sajeth] #343356
10/05/10 19:39
10/05/10 19:39
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Ehm... did you try my code?


"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: smooth(camera.pan) [Re: Superku] #343358
10/05/10 19:43
10/05/10 19:43
Joined: Apr 2008
Posts: 650
Sajeth Offline OP
User
Sajeth  Offline OP
User

Joined: Apr 2008
Posts: 650
Originally Posted By: Superku
Ehm... did you try my code?

Yep - and thanks for that - but yours reacts pretty choppy, and I figured easiest way going would be to kind of recode the smooth()-function. Thanks anyways wink


Teleschrott-Fan.
Re: smooth(camera.pan) [Re: Sajeth] #343361
10/05/10 19:51
10/05/10 19:51
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
"but yours reacts pretty choppy"

No, it doesn't. Tell me what's wrong with it!


"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: smooth(camera.pan) [Re: Superku] #343414
10/06/10 06:21
10/06/10 06:21
Joined: Apr 2008
Posts: 650
Sajeth Offline OP
User
Sajeth  Offline OP
User

Joined: Apr 2008
Posts: 650
Yes, for some reason it moves laggy as soon as the fps drop under 60. I guess with slower movement it would work fine, but not in my case.
laugh


Teleschrott-Fan.
Re: smooth(camera.pan) [Re: Sajeth] #343432
10/06/10 12:02
10/06/10 12:02
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 reason must be your "target_pan", because my game still runs smooth at 30fps or less.


"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
Page 1 of 2 1 2

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