How do I work out when a collision is made by two specific objects. Example BallA and BallB when they collide make a sound, but if they hit a wall they do not?
The function below does not work, it plays a sound no matter what they hit, walls and ceiling, I just want to play a sound when ballA and ballB collide? the print line is reporting the correct collisions.
local function myCollision(self, event)
if { event.phase == “begin” } then
print (self.myName … ": hit " … event.other.myName) --this works
if {self.myName == “ballA” and event.other.myName == BallB } then
audio.play(clicksound)
end
elseif { event.phase == “ended” } then
print (self.myName … ": collection ended with "… event.other.myName)
--audio.play(clicksound)
--end
end
end
thank you