I probably have the math wrong here for the lerp value I haven't done this in awhile Swa圜Frame = Swa圜Frame:Lerp(CFrame.Angles(math.sin(X) * SwayEffect, math.sin(Y) * SwayEffect, math.sin(Z) * SwayEffect), SWAY_SPEED*CurrentTime) - I probably have the math wrong here for the lerp value I haven't done this in awhileĪrms:PivotTo(LastCameraCFrame * Swa圜Frame) -replaced 'SetPrimaryPartCFrame' because it has been superseded by 'PivotTo'ĬurrentTime -= TIMES_PER_FRAME -you could also use the modulus operator here, but both would achieve different results in the event of noticeable lag over a durationĪlso, just a side note in case you didn’t know, when declaring variable constants (variables that don’t change like SWAY_SPEED) the standard naming convention is to use all uppercase, as this helps separate between your constants and normal variables and makes the code slightly more readable. Local Rotation = camera.CFrame:ToObjectSpace(LastCameraCFrame) RunService.RenderStepped:Connect(function(DeltaTime) - sway Local CurrentTime = 0 - a local variable for storing the current elapsed time value Local SWAY_SPEED = 1 -the speed you want the arms to sway at (you'll want to mess around with this) local TIMES_PER_FRAME = 1/20 -how often you want to update the camera every second (20 in this case) What you need to do is create a variable to store the time passed and use this as measure for limiting the rate. However, you must keep in mind that this is not the total time passed. Because this runs on the users hardware, the values this normally fluctuates between (ignoring lag) can be different for each device. The deltaTime argument that is passed to the connected function is the time that elapsed since that last RenderStep. What you want is to limit the rate, correct? Doing so is a relatively easy task if you understand the math and don’t overthink it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |