Hey guys! So I’m trying to have my enemy shoot out flowers from the top of it’s head, where each flower spins at a different angle, and also shoots out at a different angle. This is what I’ve coded.
I have a good idea what’s going wrong- I can tell when I play the game to test the attack, that the flowers fly in a ‘jittery’ fashion, and their rotations are virtually the same as they go through the air.
I’m almost completely certain that the random degree rotation, and the instant force, are constantly being updated for each flower.
All I’d like, is for each flower to be given the random degree instant force, and the random rotation number once, and then have it let it go from there, so each flower feels more unique from each other. I’ve tried trigger once (Under 'Repeat for each instance of FlowerAttack), for example, and it just let the flowers fall to the ground and be deleted. I’d love some help or suggestions, thank you so much!
Have you tried moving the rotation and force actions into the event above (i.e. out of the foreach loop)? I don’t think you should need the foreach there…
I haven’t tested that, but maybe that’ll work, or at least let you add the ‘Tigerr once’ condition and have that work as expected…
With every frame, you are setting the rotation speed to a random value. Over time, the randomness will average out to roughly the same value for all FlowerAttack objects.
What you should do is set an instance variable to hold the random rotation speed. Do this when you create an instance of the FlowerAttack object (so in the second event in your screen shot). Then use this variable to rotate the FlowerAttack object.
You can make the event changes that @BWPanda has suggested in his screen shot. Although these aren’t necessary, they are good practice as the
'Repeat for each instance' isn’t the most efficient of event controls.
That’s what I was thinking, that the randomness averaged out!
And I did the changes that @BWPanda said (Thanks Panda!) But yeah it’s still averaging out. I guess because I should then take what you said about the instance variables. I’m still a little confused on the instance variable part however. How would I go about doing that?
I’ll play around with my code in the mean time, see if I can figure it out. Thanks a ton yall!
EDIT: Actually @MrMen the more I look at what you wrote, the more it somehow feels like Chinese to me. I’m not sure why it’s not clicking but it isn’t, I apologize.
Leave the condition empty for rotate (Add rotate without condition 360 speed for example )
try to change the gravity when the flowers is near your character
Flower distance to box is below 400 pixels>> change gravity for the flowerss and make it random in range whatever you want to make it feel different
Hey I figured it out! This seemed to work perfectly, I re-read what MrMen said, and found the ‘repeat for each instance’ option, then by having the trigger once create a force, that force was the only one exerted on the flowers!