Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 839 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
smooth() #458832
04/01/16 17:02
04/01/16 17:02
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,

With the code below I try to smoothly let player weapon follow the player camera though smooth() in a first person game. But it sometimes looks a bit laggy when I rotate the camera on e.g. 40 fps as if the fps is ~20 fps. If I remove the code lines with the smooth() function the small (but still noticeable) lag is gone.

Code:
vec_set (playerWeapon.x, vector (10, 0, -7)); 
vec_rotate (playerWeapon.x, camera.pan); 
vec_add (playerWeapon.x, camera.x); 
playerWeapon.z -= 1;
vec_set(playerWeapon.pan, camera.pan); 
smooth(playerWeapon.pan,0.75);
smooth(playerWeapon.tilt,0.75);
smooth(playerWeapon.roll,0.75);



Anyway to solve this? tia

Re: smooth() [Re: Reconnoiter] #458834
04/01/16 18:46
04/01/16 18:46
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Never mind, this works better:

playerWeapon.pan += clamp(ang(camera.pan - playerWeapon.pan) * 0.5, -20, 20) * time_step;


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