I have a variable, colliding, that should check if two rects are colliding. The collision works fine most of the time, but when trying to check if the rects are NOT colliding, the if statement passes regardless of if they are actually colliding. After some logging, I discovered that the collision statement returns False most of the time, but returns True about 1 in 5 frames if the rects are colliding. I double checked that my rects are actually colliding, and are formatted properly.
Here is the relevant code:
colliding = pygame.Rect(self.objRect).colliderect(pygame.Rect(player.rect))
if player.jumping:
player.jumpTimer += 1
if player.jumpTimer >= 60:
if not colliding:
player.jumping = False
player.jumpTimer = 0
else:
#logic that is running when it shouldn't
ThisOneRandomGy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.