I need help with code for my game

Hello
I need help with the following code for a project. I generated random obstacles and a running character. I have entered the following code for the character clashes against both the ground and the obstacles. How can I make it collide only against the obstacles and that’s it?

local function onPlaneCollision(self,event)
– se la collisione è in fase iniziale
if event.phase==“began” then
– elimina l’ascoltatore tapPlane
plane:removeEventListener(“tap”,tapPlane)
– rendi plane invisibile
plane.isVisible=false
– rendi lo sprite explosion visibile
explosion.isVisible=true
– posiziona l’esplosione alle coordinate di plane
explosion.x = plane.x
explosion.y= plane.y
– anima lo sprite explosion
explosion:play()
– altrimenti se la collisione è appena terminata
elseif event.phase==“ended” then
– chiama la funzione gameOver
gameOver()
end
return true
end

Hi, @Andrew_TDT,

Use Collision Filtering

Have a nice day:)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.