Hi! In my game I have magnets which draw the player closer to them if the player is on the same position as them.
I currently iterate through each magnet on screen with a loop but want to detect when the player isn't on any magnet at all.
Example psuedo code
The problem I'm having is that if the player is not on 1 magnet position DragPlayer will = 0. So if I had 2 magnets stacked on top of eachother if the player is not on one of them DragPlayer will = 0.
So, how would I go about checking if the player isn't on any magnets at all so that i can reset the movement?
I hope this made sense. :)
I currently iterate through each magnet on screen with a loop but want to detect when the player isn't on any magnet at all.
Example psuedo code
For Local MagnetIter = 0 To Number Of Magnets If PlayerY is > MagnetYPos[MagnetIter] - 32 And < MagnetYpos[MagnetIter] DragPlayer = 1 Else DragPlayer = 0 EndIf Next If DragPlayer = 1 Move Player closer To magnet ElseIf DragPlayer = 0 Do nothing And keep player at position End If
The problem I'm having is that if the player is not on 1 magnet position DragPlayer will = 0. So if I had 2 magnets stacked on top of eachother if the player is not on one of them DragPlayer will = 0.
So, how would I go about checking if the player isn't on any magnets at all so that i can reset the movement?
I hope this made sense. :)