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
  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,404 04-02-2023, 12:14 PM
Last Post: _Aka_

Forum Jump: