05-11-2019, 07:26 PM
(05-11-2019, 02:48 PM)_Aka_ Wrote: Hi,
Speed is either in world units or relative ones based on Move Mode
Position is based on Position Mode
More about this here: https://curvyeditor.com/documentation/controllers
I didn't get the logic behind the position computation, especially the lerping using deltaTime * 1000, but I will take your computation as it is, and give you how you should compute the speed:
Code:float nextPosition = rhythmTool.currentFrame - InfiniteTrack.Instance.lengthCut;
float realNextPosition = Mathf.Lerp(Position, nextPosition, Time.deltaTime * 1000f);
float oldPosition = Position;
Speed = (realNextPosition - oldPosition) / Time.deltaTime;
This should do the work. Let me know if it doesn't.
To clarify why I don't like the lerping you did: it will make your game frame rate dependent. In other words, if your ship moves for a second at 30fps, or a second at 60 fps, the results will be different, because Lerp(Lerp(A,B,X),C,X) is different than Lerp(A,C,2*X)
Hello. Thanks a lot for answer. Your solution works, but today before I checked your answer I already found working solution. It's similar but formula is:
Speed = (realNextPosition - oldPosition) * rhythmTool.interpolation * 30f;
Let me explain:
rhythmTool.interpolation is a time between music frames. Frames are constantly 30 per second, so I mult it to 30. Is this better than division on Time.deltaTime, what do you think? music frames per seconds are always 30, not depening on game fps.