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
0 registered members (), 18,561 guests, and 5 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
[SOLVED] what is wrong with this change camera.pan code? #453895
08/18/15 11:45
08/18/15 11:45
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi,

I use the following code when smoothly zooming in to the front of entities, but sometimes the camera shakes heavily when it is near its chosen/designated pan (/angle). It has seems to shake when the pan/angle of the target has decimals (/not a nice integer number).

This is e.g. with a fps of 50-60;

Code:
function cam_focusonentity()
{
  while(...)
  {
  ...

  //change pan angle
  if (1 < abs(target_ent.pan+180-camera.pan)) camera.pan += 4 * time_step * sign(ang(target_ent.pan-180 - camera.pan));
  
  ...
  wait(1);
  }
}



The code line is a bit long, but it was the only way I knew how to make it that the angle is changed evenly and always reached its target.

So anyone know how to prevent it from shaking?

[FOR SOLUTION SEE MY 2ND POST]

Last edited by Reconnoiter; 08/18/15 18:02.
Re: what is wrong with this change camera.pan code? [Re: Reconnoiter] #453906
08/18/15 16:44
08/18/15 16:44
Joined: Aug 2015
Posts: 10
Michigan
41Lumber Offline
Newbie
41Lumber  Offline
Newbie

Joined: Aug 2015
Posts: 10
Michigan
Try this (full line) instead:

Code:
camera.pan += ang(target_ent.pan+180 - camera.pan) * minv(1, 4 * time_step);



The minv call is there so that if your frame rate dips below 16fps (time_step = 1), it won't overshoot and cause a violent shaking effect. Tweak the 4 if the rotation is not smooth enough for your liking (smaller number = more smoothing).

Re: what is wrong with this change camera.pan code? [Re: 41Lumber] #453912
08/18/15 18:00
08/18/15 18:00
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi 41Lumber,

Thanks for replying.
The problem with that code line is that in the beginning it goes to fast (disorientating) and at the end it goes to slow resulting in that it doesn't always finish to the end.

I found a solution though. I added a few lines to check when the sign() of camera.pan increasement suddenly changes, if so I stop the change pan code. It works really nice so far.

Anyway thanks for your time.

Last edited by Reconnoiter; 08/18/15 18:02.

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