Jump to content

photo

Recommended Posts

Hi Unigine Team,

 

I verified  MathLib.Lerp , this function have a bad bug.

 

If the distance from the origin to the destination increases, The shooting point to the destination happens with a fast time interval! this is not correct!
While this process should be uniform as a third parameter(speed*Game.Ifps).
For example :
The starting distance to the destination is 10 meters and the particle travels this distance in 2 seconds

For example :The starting distance to the destination is 100 meters and the particle travels this distance in 20 seconds

 

I think this function needs to be reviewed , or at least create another function, according to me, so that missiles and rockets can be designed.

 

Thank you

 

Link to comment

Hi ahmad,

actually your pointed out behavior from lerp is the expected behavior and not a bug. Have a look at the actual implementation:

v0 + (v 1 - v 0) * k

 

With increasing distance between v0 and v1 becomes greater even for the same k-value. So to get your proper result you have two choices: Either modifying k-value resprecting the distance (maybe something like speed / length(v1-v0) * iFPS) or using a normalized direction vector that will be used for movement calculation.

 

 

 

 

  • Like 1
Link to comment
17 hours ago, christian.wolf2 said:

Hi ahmad,

actually your pointed out behavior from lerp is the expected behavior and not a bug. Have a look at the actual implementation:

v0 + (v 1 - v 0) * k

 

With increasing distance between v0 and v1 becomes greater even for the same k-value. So to get your proper result you have two choices: Either modifying k-value resprecting the distance (maybe something like speed / length(v1-v0) * iFPS) or using a normalized direction vector that will be used for movement calculation.

Thank you so much , I know this your tip, I tested LOT ,  I did Lerp in unity for 5 years , this issue is correct in unity but for unigine is not correct (MathLib.Lerp)

Link to comment
1 hour ago, silent said:

Is there any chance to take a look at the minimal test scene where lerp is not working as you expected? Are you sure that you are not mixing lerp and MoveTowards (from Unity)?

Thanks!

Hello Mr @silent

MoveTowards function is exist for unigine in c#?

I tested lerp function a lot for unigine , but the result is strange, I'm working on it.

Link to comment
18 hours ago, christian.wolf2 said:

Hi ahmad,

actually your pointed out behavior from lerp is the expected behavior and not a bug. Have a look at the actual implementation:

v0 + (v 1 - v 0) * k

 

With increasing distance between v0 and v1 becomes greater even for the same k-value. So to get your proper result you have two choices: Either modifying k-value resprecting the distance (maybe something like speed / length(v1-v0) * iFPS) or using a normalized direction vector that will be used for movement calculation.

 

 

 

 

Thank you @christian.wolf2 , I test your solution soon , I report result that here

Link to comment
×
×
  • Create New...