- Home /
Why is Vector3.Lerp slower than function Lerp (a,b,c):Vector3{...
When i was editing marching cubes, i found that Mathf.Lerp seemed a bit slower than a function of Lerp written in the same script as the marching cubes code. (Unless someone shows otherwise)
Could you give me a technical explanation about the unity engine, of how it accesses unity functions, so that i can understand the code engine better?
this was fastest:
function lerps(o:Vector3, v:Vector3, alpha:float):Vector3
{
o.x += ( v.x - o.x ) * alpha;
o.y += ( v.y - o.y ) * alpha;
o.z += ( v.z - o.z ) * alpha;
return o;
}
By ast do you mean the cube moves faster or that it gets calculated faster? I don't know if you can look at the code behind the unity functions (probably not) but vector3.lerp is explained pretty clearly.
the total time for processing was less with lerps function. the marching cubes takes a value for the corners of every cube, and the lerps places the vertex on the edge between 2 corners using lerp.
Answer by GameVortex · Feb 07, 2014 at 02:57 PM
Vector3.Lerp also clamps the time value down to be between 0 and 1 using Mathf.Clamp01 which has two if checks in it. So it does slightly bit more than what your function does.
Your answer
![](https://koobas.hobune.stream/wayback/20220613132819im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Increase/reset speed on tilt 0 Answers
Mathf.Smoothdamp, need help troubleshooting! 0 Answers
How do I increase a speed variable over time? 1 Answer
Ramping animation speed 2 Answers
Not Run while Aiming; Slope Terrain Making Object Faster 0 Answers