Create object at specific offset

Hello guys,

I need some help.

Let’s say i have a music, and i want to create an object when the offset of the music reach to a group of specific time

I have numbers 2,6,11,16,28,34
i want to create an object when the offset of the music is equal or greater than 2 and create another object when the offset of the music is equal or greater than 6 and then another at 11 and so on.

Is there a way to do that in one event using some sort of array of variables or something like that and not making separate events for each number?

something like storing all the numbers in one group of variable and make one event that do:
trigger once
when the offset of the music is equal or greater than [list of variables] > create an object

Any help would be appreciated

There is a condition on checking offset:

But for this, you need to play the sound in a channel

Hi maybe you can use a collection structure of data to store 2,6,11,16,28,34

Something like this

Don’t forget to set all added values to number
Later in your game I suppose you want to check against some other variable so do like this

You check if inside of the structure there is a child with the value of otherVariableMusic

Is there a reason to use structure and not array?
And how do I set all added values to numbers?

Thank you for your reply

Well for me the main reason I don’t use Arrays is because sometimes I need to define the pair KEY/VALUE and the arrays only accepts numbers as key and always start from 0. but usually I sue this for Player data like
Key->Hp — Value->100 so later is easy to find instead of array that would be like KEY->0 VALUE->100 so if I forget that the key 0 of the array is the hp of the player I’m f**cked

ok thank you for explanation
And how do I set all added values to numbers?
cause from what I understand structures are string values.
And for the offset I need number values

You can set the type of value like this

Add an structure variable then add some keys that you easily can remember in this case the keys and the values are the same but only are going to use the values
If you want to get this more clear do like this:

So you make sure that each child of the variable has a key name that identify the number for instance
Key->offset2 Value->2

1 Like

I’ve tried your solution, it kinda works and kinda don’t. It only creates object at the first variable in this case the variable with value 2. Once it creates one object at the first variable then it won’t trigger at those next variables (6,11,16,28,34).
Is there a way to fix this?

Sorry I don’t understand what you’re saying please share some screenshots of your events so I can see and help you better

I know it’s a little bit confusing, basically what I’m trying to do is when the offset of the music is equal or bigger than the variable it creates an object at a random position. I’m trying to make something like the game “OSU” where you have to click on notes base on the beat. I actually have a list where i have the timestamps of every beat in the one music I’m using in this game and I’m trying to manually type in the timestamps into the variables to let the system know when to create a note or beat to let player click.
Hope i explained clearly this time

this is my variable (timestamps when to create beat)

this is my event

I’m guessing here but I think you need a parent Foreach NewObject so the next event were for every child can identify wich NewObject need to use
Main event
For each NewObject
For every child…
The playing… → Create NewObject2 at NewObject.X(),NewObject.Y()

So this way every NewObject get at least one pass thru the foreach

Tip: Please try to name properly your objects so it’s easy for you to identify what is each object.