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
  Can you move generated objects along spline? FernDigestive 1 8 04-02-2023, 12:14 PM
Last Post: _Aka_
  Feature Request-move UI elements in SceneView spawnstorm 5 20 09-17-2022, 12:37 PM
Last Post: _Aka_
Wink In SplineController OnPositionReachedList Event is missing shimizu 2 13 02-07-2022, 12:47 PM
Last Post: shimizu
  best way to rotate, change offset, and inset position of splinecontroller object smackledorf 1 24 01-17-2022, 01:39 PM
Last Post: _Aka_

Forum Jump: