Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move SplineController in rhythm of song
#4
(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.
Reply


Messages In This Thread
RE: Move SplineController in rhythm of song - by electricpunch - 05-11-2019, 07:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Play() does not cause SplineController to produce expected behaviour ConCat 8 1,390 02-08-2026, 11:54 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,468 07-29-2025, 09:15 PM
Last Post: _Aka_
  Player move with object mcarman 4 2,987 07-29-2024, 06:49 PM
Last Post: mcarman
  Can you move generated objects along spline? FernDigestive 1 1,403 04-02-2023, 12:14 PM
Last Post: _Aka_

Forum Jump: