Skip to main content
The 2025 Annual Developer Survey is live — take the Survey today!
23 votes
Accepted

Why use Time.deltaTime in Lerping functions?

See also this answer. There are two common ways to use Lerp: 1. Linear blending between a start and an end ...
DMGregory's user avatar
  • 139k
5 votes

Why does the kinematic body move in opposite direction after I interpolate its movement, and how do I fix it?

You can't rely on movement.x hitting 0. This is because floating point errors. Instead, check if it is closer to 0 than ...
Theraot's user avatar
  • 28k
4 votes
Accepted

GLSL "varying" interpolation: component-wise? Reference in the spec?

TL;DR: Yes, it is component-wise. As you said, GLSL specifications have formulas for computing "datum associated with a fragment", like this one: GLSL 330 spec : 3.5.1 Basic Line Segment ...
HolyBlackCat's user avatar
  • 2,055
4 votes
Accepted

How to smooth rotations?

Yes, in fact that's what quaternions are often used for - interpolating between two different orientations. Other methods of representing orientation suffer from issues like gimbal lock and wrap-...
congusbongus's user avatar
  • 14.9k
4 votes
Accepted

Fixed Timestep with Interpolation | Blurry & Choppy

Your lerps and slerps are backwards: lerp(current, previous, alpha) should be lerp(previous, current, alpha) ie. ...
DMGregory's user avatar
  • 139k
4 votes
Accepted

Why do my sprites jitter when moving diagonally?

With out code, this might be hard, but if I had to take a guess, your sprites aren't gittering, your camera is. I suspect you are moving the camera either to the exact x or y position both when ...
Krupip's user avatar
  • 1,793
3 votes
Accepted

How to smoothly interpolate 2D camera with pan and zoom

For a smooth loop like this, we want to scale the camera viewport from 1 x at the start to \$r\$ x at the end of the first loop (where \$r\$ is the ratio between the inner image size and the outer ...
DMGregory's user avatar
  • 139k
3 votes
Accepted

Suitable interpolation for animating explosions

There are multiple easing functions (https://easings.net) that can help you, more specifically "ease out" functions (faster at the beginning, slower at the end). I have all of those in the ...
Ferreira da Selva's user avatar
3 votes
Accepted

How to smooth viewport panning when using minimap (in typical RTS)?

I think you should avoid setting your viewport position to the value selected in GUI in one, single frame. Instead, I'd add a target position and ...
kolenda's user avatar
  • 1,420
3 votes

Given a set of points with color values, finding a gradated color value from a given position

An idea that occurs to me would be to use something like Voronoi cells to split the area by color, and sort of blend them into each other. Essentially past the border between two colors use a smooth ...
Will Mungas's user avatar
3 votes
Accepted

D3D12: how to enable perspective correction when interpolating UV coordinates?

You've lost perspective correctness due to the way you've written your vertex shader. Ordinarily, we'll transform our vertex from view space to clip space by multiplying it by a projection matrix that ...
DMGregory's user avatar
  • 139k
2 votes

Why is interpolation passed into the rendering routine when the position and speed are related to the update routine?

Combining a physics engine that uses a fixed time-step with a variable-timed rendering loop can lead to very choppy movement. Sometimes you have two physics frames between two renders, sometimes none ...
Philipp's user avatar
  • 123k
2 votes

HeightMap from a graph

TL;DR: Use bicubic interpolation or spline interpolation. So, you're looking for a method of two-dimensional interpolation. Unfortunately, this isn't a perfect two-dimensional grid (mathematically, it'...
HDE 226868's user avatar
2 votes

Suitable interpolation for animating explosions

Yes, the velocities are the highest at detonation time, and as the explosion progresses, the system loses energy. So fast growth that fizzles out would be a good model. So a function with a fifth ...
Bram's user avatar
  • 3,744
2 votes
Accepted

Aim/Scope Oscillation Algorithm

Using polar coordinates would do the trick. Here’s a graph of the function r=sin(2.3θ), with θ going from 0 to 2π: Given ...
Noah Witherspoon's user avatar
2 votes
Accepted

How do I interpolate an object from point A to B such that it accelerates, overshoots, and bounces back to target position?

A few small fixes: Cache your initial position, and lerp from there to your end, to avoid a feedback loop where transform.position is being used to modify itself. ...
DMGregory's user avatar
  • 139k
2 votes
Accepted

Slerp to slerp smoothing

I hadn't actually aligned in CatmullRom, it was one of my other tests. It got lost in all the messy code. The problem was solved by aligning the start and end points of the spline input. (params: pre, ...
John Smith's user avatar
2 votes

How do you determine which 4 pixels to interpolate, using bilinear interpolation?

Conventionally, the pixels (or "texels") in a texture are arranged in a 2D grid. Let's say it looks like this: ...
DMGregory's user avatar
  • 139k
2 votes

Trouble getting the right Interp Speed with 'FInterp To' node

So I was wrong about the value of DeltaTime of FInterp To I hadn't use the EventTick in the <...
Ariya Rivandi's user avatar
1 vote

How to smoothly interpolate 2D camera with pan and zoom

Here is my solution based on the answer given by DMGregory. This is Delphi Pascal. The LinearInterpolate function is just a lerp. Care has to be taken to avoid ...
XylemFlow's user avatar
1 vote

Camera Jitters When Displacing and Rotating Smoothly

Your GetSmoothFollowRotation() function is wrong. SmoothDampAngle gives you an angle in degrees (0-360 or -180-180), but you're ...
DMGregory's user avatar
  • 139k
1 vote

Interpolating between positions unfeasible at 30 frames per second?

I think this article summarizes the problem you are seeing FIX YOUR (UNITY) TIMESTEP! You could calculate your fixedDeltaTime like: ...
Juri Knauth's user avatar
1 vote

Godot 3.0 Constant 2D Angular Velocity

@skrx "+1" Thanks! I wasn't able to make get_local_mouse_position().angle_to_point(position) work as intended, but using your method of angular speed, I was able to rework it to suit my purposes: <...
Meizikyn's user avatar
1 vote
Accepted

Godot 3.0 Constant 2D Angular Velocity

A simple solution would be to get the angle to the target and then just rotate counter-clockwise if the angle is negative and clockwise if it's positive: ...
skrx's user avatar
  • 335
1 vote
Accepted

Can't figure out what's making the player teleport back to spawn

Your method for blending to the new updated position definitely looks dicey. While there are times when we want to use the pattern ...
DMGregory's user avatar
  • 139k
1 vote
Accepted

Smooth Rotate Object While Orbiting

For anyone running into a similar issue, the solution (for me at least) was to just change it to rotating around the local z-axis rather than the world z-axis: ...
DRiFTy's user avatar
  • 586
1 vote

Fixed timestep updates with a variable timestep update

The reason we do fixed timestep updates in the first place is to ensure our realtime game simulations stay consistent. Take a simple object falling under gravity of -9.8 m/s^2 under Euler integration,...
DMGregory's user avatar
  • 139k
1 vote

Why use Time.deltaTime in Lerping functions?

You are right, the method Quaternion Slerp(Quaternion a, Quaternion b, float t) interpolates between a and ...
Ludovic Feltz's user avatar
1 vote

Why use Time.deltaTime in Lerping functions?

I think the core concept missing would be in this scenario A is not fixed. A is updated with each step, by however much along the interpolation that Time.deltaTime is. So, with A getting closer to B ...
CLo's user avatar
  • 1,330
1 vote
Accepted

Calculating t value to use with Hermite interpolation

It depends on what you want. It's always a trade-off between having to wait occasionally or having a longer lag. You can trade one against the other (by specifying your desired optimal buffer size). ...
NoDataDumpNoContribution's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible

X