Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Thanks Kenny, I'm glad you found it helpful!

If the object is already instantiated, you'll probably want to use something like: this.gameobject.SetActive(true) to make it appear and SetActive(false) to make it disappear.

To time it to the beat you will have to check the Conductor beat. Something like If(Conductor.instance.SongPosInBeats > this.appearBeat)

this.gameobject.SetActive(true)


Then do the same for making it disappear. If you're having it appear and disappear in a loop, you will have to reference the Conductor.instance.loopPosInBeats


Try playing around with that and see if it works!

Deleted 4 years ago
Deleted 4 years ago
(1 edit)

Ok I start to understand. 

I know if you want to access to another game object you have to call it through fonction or declare it as a variable right?

But I don't really  understand the concept of instance.

What is it for exactly?


(I see you are canadian so you can explain me in french if you want)

Sorry your English seems much better than my French.


On the Conductor class I made a static Conductor variable called instance. This just makes it easier to call Conductor from other functions. The Conductor script is attached to a  GameObject in Unity (let's say it's attached to an object called ConductorObject). Usually you would have to have a way to link to that specific GameObject in order to reference ConductorObject.Conductor. Instead, using instance, it makes sure there's only one version of the Conductor script running in Unity. Then you can call it using Conductor.instance and access all the variables and functions of that specific Conductor script without having to declare it as a variable in another script.


I hope this is clear. This is typically done for a GameManager script in other games, so you may be able to find tutorials for that class that would be helpful.

(1 edit)

Oh yes this is very clear!

 You know what? I just spent hours trying to link other GameObjects to that   Conductor script rrr, so I really know what you mean now aha!

 So now that I succeeding to set a GameObject Active according to the SongPositionInBpm, I still have a little problem.

I have a script which look like this:

if (songPosBeat >= 5)

        { gameObject.SetActive(true); }
        

But the GameObject become active a little ahead of time before songpositioninbeat reach 5.

It's quite noticeable.


 Do you have any idea?


Thank you to spend your time to answer me. I'm so noob sorry.

Hmmm, hard to say without seeing the code. Make sure the variables are all named correctly and see what the values are at activation with Debug.Log. maybe something's slightly off!

you may also find it helpful to look at the code I used for Atomic Beats: https://github.com/billtg/Rhythm-Pattern