I’m working on a game where I have a platform where a character is allowed to pass through depending on the type of platform. So I have used pre collision to see if the contact should happen. However every once in a while, and this is rare so its hard to replicate but every once in a while it seems that event.contact == nil, I have even tried adding in a check to see if event.contact at the beginning but once in a while I keep getting errors.
local function passHit( self, event ) local other = event.other if event.contact then if self.data.side == "bottom" then if self.y + 24 \> other.y then event.contact.isEnabled = false end elseif self.data.side == "top" then if self.y - 24 \< other.y then event.contact.isEnabled = false end elseif self.data.side == "left" then if self.x - 24 \< other.x then event.contact.isEnabled = false end else if self.x + 24 \> other.x then event.contact.isEnabled = false end end end end