smooth()

Posted By: Reconnoiter

smooth() - 04/01/16 17:02

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
Posted By: Reconnoiter

Re: smooth() - 04/01/16 18:46

Never mind, this works better:

playerWeapon.pan += clamp(ang(camera.pan - playerWeapon.pan) * 0.5, -20, 20) * time_step;
© 2024 lite-C Forums