Skip to content Skip to sidebar Skip to footer

How To Check Which Object My Character Is Colliding With?

I am working on collision detection for a game, so that if the character runs into an object they stop moving. As part of my solution for this, I have made two functions that iter

Solution 1:

I think you need to simply change:

self.x = ((listofwidgets(i).x + listofwidgets(i).width + .1)-self.x) + self.x

to:

self.x = (i.x + i.width + .1)-self.x) + self.x

Also listofwidgets(i) would be a function call, it should probably be listofwidgets[i] (if it wasn't just a typo)

Solution 2:

listofwidgets(i) is the object you are colliding with, so either store that widget, or i in a variable for later use.

Post a Comment for "How To Check Which Object My Character Is Colliding With?"