Jump to content

Alternative for onClientRender


mustang

Recommended Posts

Hello guys ,

I would like to know if there is any alternative for "onClientRender" or "onClientPreRender" because iam working on a new project the uses alot of this event , the problem with this event is that it depends on the player's FPS , which will effect the results of my script in example : the time it takes to move an object 1 unit forward for every frame on a player's machine that is running 100fps will take less time than a 36 fps machine . I suppose you understood what i meant so i need a way to move that object with same time it takes for all players , you would tell me to use "setTimer" but it is too slow and wont give me a great smoothness as the "onClientRender" would give.

If you need more information of what i need just post a comment .

Thanks.

Link to comment

The dt parameter represents the time taken between the last frame and the current. You can use this value to calculate the step accordingly to the player's FPS. E.g. say you want to move your image on the screen to the right. Instead of doing the usual "posX = posX + 1" where posX would be the current image position X and 1 the step, you would multiply 1 by dt, as in "posX = posX + 1 * dt", therefore achieving a smooth movement independently of the player's frame rate. This is called variable timestep.

Link to comment
The dt parameter represents the time taken between the last frame and the current. You can use this value to calculate the step accordingly to the player's FPS. E.g. say you want to move your image on the screen to the right. Instead of doing the usual "posX = posX + 1" where posX would be the current image position X and 1 the step, you would multiply 1 by dt, as in "posX = posX + 1 * dt", therefore achieving a smooth movement independently of the player's frame rate. This is called variable timestep.

i think i got it , Thanks man , i will try it and give you the results :wink:

Link to comment
The dt parameter represents the time taken between the last frame and the current. You can use this value to calculate the step accordingly to the player's FPS. E.g. say you want to move your image on the screen to the right. Instead of doing the usual "posX = posX + 1" where posX would be the current image position X and 1 the step, you would multiply 1 by dt, as in "posX = posX + 1 * dt", therefore achieving a smooth movement independently of the player's frame rate. This is called variable timestep.

i think i got it , Thanks man , i will try it and give you the results :wink:

I am having some trouble doing it , for example if i want to move the object 1 unit in (Y) for everyframe what would delta be if my fps was 100 ? i mean i need to move it 1 unit only if my fps was 100 then what would be the script ? This is totally a new thing for me , sorry for that :?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...