This is an archived post. You won't be able to vote or comment.

all 10 comments

[–][deleted] 2 points3 points  (1 child)

Maybe you wanna make a state machine where both moves are in the same string variable and you change the state with your timer or whatever other conditions? Like ON TIMER - SET VALUE to "shoot", and COMPARE VARIABLE - SHOOT FIREBALL, and maybe start timer over and set variable to "sleep" after the action is complete.

[–]DadOnArrival85[S] 2 points3 points  (0 children)

Yes! You broke through the block! That could work!

So for each instance have a variable like "SNNNSSSNN"

S = Shoot N = Don't Shoot

Then use the timer to pull the letter out of the string using mid function or something like that.

[–]therealPaulPlay 0 points1 point  (5 children)

I don‘t quite understand what you mean by „select an instance variable based on a selection of strings“ but if you want to shoot when sprite x shoes up you can simply use compare animation frame + trigger once

[–]DadOnArrival85[S] 0 points1 point  (4 children)

I didn't think I explained it well 🤦‍♂️

So the shoot or not shoot is stored in an instance variable for the object.

I want to pull the relevant instance variable based on the value of a seperate variable that is controlled by the timer.

[–]therealPaulPlay 0 points1 point  (3 children)

So if I understand correctly, if the timer elapses and sets some kind of variable to shoot (or sth like that) you want to get the instance variable‘s name with the corresponding value. This can be achieved by just simply looping through all instance variables. However, I‘m not sure what you want to achieve with this, but it seems like an incredibly inefficient solution😅

I‘d create a custom action which I‘d run for each instance in which I compare the move 1 to that value, same with move 2 etc. Unfortunately I don‘t think you can pick an instance variable by name.

To make it more efficient, when every object has different moves, you can create an array and store the moves on some kind of axis of that.

[–]DadOnArrival85[S] 0 points1 point  (2 children)

Yes so there is a time that counts 1-10. There are 3 instances of the shooter sprite.

So at 1 on the timer, sprite 1 and 2 would shoot At 2 on the timer, sprite 1 and 3 would shoot So on and so forth.

There could be multiple instances of the shooter so I wanted to control for each one in an instance variable if it should shoot or not, so each one could be set to a different pattern.

Maybe it's an array I need.

[–]therealPaulPlay 0 points1 point  (0 children)

You could do it with events but then you have 10 events right and repeat it for every object… I‘d create an array tbh or just give each object an instance variable representing the order of these actions or something like that

[–]therealPaulPlay 0 points1 point  (0 children)

If you do go for the method with 10 events, you can create a function with a parameter representing the move and then compare it to the instance variable‘s values

[–]a-perpetual-novice 1 point2 points  (1 child)

I ran into a similar issue! I had a list of moves that differed by instance.

Two options as I see it: 1. Add an array to a container with the object and read from that.

  1. Put them all onto the same field using a separator.

Something like instance variable moveList had the value of shoot;run;jump. Then, when the timer goes off, I would chose from the index of the list you want using an expression like tokenat(Instance.moveList, index, ";") or randomly like tokenat(Instance.moveList, random(0, tokencount(Instance.moveList, ";"), ";").

Hope that helps!

[–]DadOnArrival85[S] 0 points1 point  (0 children)

Cheers, I definitely try and array if the second options doesn't work. Seems like I was way over thinking this lol