- Home /
How to move sprites to match the tempo of a song (rhythm game)
I am developing a rhythm game prototype in unity. To get the rhythm game to sound right i need to match up my sprites (notes) to the bpm/tempo of the song i am using.
So to address this I added a calculation into a script to move the sprites, I have a public variable called "beatTempo" and then i calculate the amount the sprites need to move.
beatTempo = beatTempo / 60.0f;
I then transform the sprite by: beatTempo * Time.deltaTime
So in theory the notes should move and match the audio source in my scene if i put in beatTempo = 120 for example.
I found that this calculation works inside of world space just fine but because i am working inside a canvas the calculation makes the sprites move extremely slow in canvas, but they move just fine in normal world space. Does anyone know the difference of units inside a canvas compared to world space so i can match up the bpm to the sprites?
It depends. You want to look at the CanvasScaler component on your Canvas...
Answer by Batzuga · Feb 07, 2020 at 10:18 PM
You really shouldn't be making moving game mechanics inside a canvas. Just create 2D sprites in the world space, and just use the Canvas for the UI.
I initially was concerned with this too. Problem is we are developing a 3D game and I wanted to overlay the rhythm game on top of the 3D scene, is there any way to incorporate a flat 2D hud like game inside a 3D project?
I guess I could just incorporate the mechanic into the actual 3D scene, sticking the game on a "TV Screen" model or the likes.
Your answer
Follow this Question
Related Questions
How to manipulate sprites in 3D space for cockpit 0 Answers
How to display Sprite only over RawImage? 0 Answers
How to animate 2d characater Avatar (Portrait) whit dynamic changes. 0 Answers
blurred canvas images on iOS retina 1 Answer
What is the relation between Canvas, Main Camera, and Sprites. 1 Answer