- Home /
How I can do to make the objects do not take a lot of space in the game?
I'm doing a guitarhero game but the problem is that there are lots of objects in the game so the game at put it play it gets slower and slower. I try several things like put an object that has a trigger and the notes are invisible so when the notes come to that object I put to make it visible("gameObject.SetActiveRecursively(true)") but it dont seems to work. So please if some on know a way to make it faster or someone know how to make this work please help me I will realy appreciate
@unknown (google): Please stop flagging your posts as "Require $$anonymous$$oderator Attention" just because you want an answer! This is not what flagging posts is for!
Answer by joedrigon · Oct 25, 2010 at 02:34 AM
Well I assume if you are making a GH type game you will have the notes flowing down the screen at you. Are you destroying them after they get off the screen or letting just move off screen behind you forever?
yes I destroy it but the thing is that they are a lot of notes and there are all up so it could be more faster at the time but at the first is to slower
Answer by mbreen · Oct 25, 2010 at 02:44 AM
Sounds like you create all the notes at the beginning of the program and then they slowly get destroyed over the duration of the song. Wouldn't it be easier to create the notes right before they are visible to the player then they get destroyed a few seconds later. That would only mean that a limited amount of notes are being seen.
because the note are already there so if I create that they appeare(create it) in a exact moment it would be to difficult to put the correct place that the notes have to be.
what I,m serching is not a way to create in a exact moment, I,m serching for a way to make invisible the notes and then in a exact moment the notes appeare.
Answer by BerggreenDK · Dec 18, 2010 at 01:09 AM
I would make Guitar Heros clone by using a simple "tilebased scroller effect" For each "line" you need some "tiles" (notes) and these have to scroll. The maximum amount of objects you need is the amount possible at a time pr. line * lines. Cant be that hard to keep them "in memory".
Just store them all in a list/array for later usage. And when they have moved down the screen (outside view) then just move their coords outside cameraview or "disable" the rendering on them.
I've previously written about how you build a "scrolling map". Its the same thing.
How to build a level
You make 5 arrays (1 for each line) which contains the notes. You can compress these if you want by only storing the note delay. But lets say you have a bass-drum in a textstring (which is a simple type of array too)
string line1bassdrum = "*...*...*...*...*...*...*...*...*...*...*...*...*";
Then we could make the snare too:
string line2snaredrum = "....*.......*.......*.......*.......*.......*....";
The game loop
now, start at "level position 0"... the left side of the string.
You can extra the chars one at a time with "substring". Then look if there is a or a . If its a then take the first available "note object" from your array of those and place it in the far end of the screen.
Repeat this for each note line. Then you have "first row of notes".
Then do the updates until next beat is ready. This means, moving the notes forward against camera. Then when the beat is up you increment your "level position" with 1.
Then look up the char in each array/string again, and repeat the above procedure.
When a note object reaches the bottom of your screen, deactivate it (not destroy) so you can look it up in your array again.
I hope this made a little sense?