Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
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
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 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
[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 | 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