Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(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