Hello! I'm currently programming a bunch of jumping slimes, and I've run into a snag that I've experienced before, but I can't remember how to solve it!
As it is, if one slime is touching the ground while anotheri s jumping, it will mess up the jump, due to a conflict in a fastloop that says "If slime is touching ground, subtract from the y position" to avoid falling below the ground.
The code is as follows.
Height of Slime < 8
set height of Slime to Height("Slime")+0.45
Height of Slime <> 0
start loop "slime" Abs(Height("Slime") times
On loop "slime"
Height of Slime > 0
set Y of Slime to Y("Slime")+1
On loop "slime"
Height of Slime < 0
set Y of Slime to Y("Slime")-1
On loop "slime"
Slime is overlapping a backdrop
Height of Slime <0
set Y of slime to Y("Slime")+1
set height to 0
On loop "slime"
Slime is overlapping a backdrop
Height of Slime >0
set Y of slime to Y("Slime")-1
set height to 0
Now an individual slime will behave exactly like I want it to, but if there is more than one they will mess up.
I tried solving this by a spread value and then referring to it in the loop, but the problem there is that since the gravity is dependant on the "slime" loop starting Abs(Height), I can't refer to the loopindex properly as one would do with
On loop "slime"
Id of Slime == Loopindex
Slime is overlapping a backdrop
Height of Slime <0
set Y of slime to Y("Slime")+1
set height to 0
Any ideas on how to do this? If I can I'd like to keep the gravity system, as the jumps become precisely as smooth as I want them.
Any help is appreciated, thank you.