Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move SplineController in rhythm of song
#1
Hello, I have question about SplineController. I'm making a music arcade game like AudioSurf. I decided to use "50_EndlessRunner" scene as a start point and "RhythmTool" asset which allow to detect beats and onsets of music. RhythmTool divides song on frames (30 frames per second) and I decided to use frame value as position on spline to add objects (obstacles and powerups). It works good but problem is in Ship movement. Few days I tried to understand how to calculate Speed value of SplineController to move Ship in the rhythm of song. I found only 1 working solution is to set Speed = 0 and use Position parameter instead. I made own SplineController child class and in Update method I do this:
float nextPosition = rhythmTool.currentFrame - InfiniteTrack.Instance.lengthCut;
Position = Mathf.Lerp(PositionnextPositionTime.deltaTime 1000f);
"lengthCut" value is the total length of destroyed spline segments. I need to substract it because Spline is cutting when Ship achieves new CP point and Spline's initial position resets. 
This code works, BUT OnControlReachedPoint event never called and therefore infinite spline is not infiniteSmile As I understand events work only when Controller moves using Speed value. 
So my question is how I can calculate Speed to move Ship in rhythm of song or how I can use Position value together with events? 
As I know from school, Speed = Distance / Time. Where Distance = nextPosition - Position, Time = rhythmTool.interpolation (time between current and next frame). But this formula not working...Maybe you can help, I hope....I just stuck on this. Thanks in advance.
Reply


Messages In This Thread
Move SplineController in rhythm of song - by electricpunch - 05-10-2019, 09:41 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: