Topic: Car collision

Hello, I have been trying to work out how to make the car from the physics demo play a sound when colliding with anything that isn't itself. I'd rather not have to write out if IsCollisionBetween statements for everything I want it to make a sound with colliding with. So far i've tried using getNumCollisions with no luck. Could anyone please help?

Last edited by Almighty Laxz (2012-08-09 08:15:14)

Re: Car collision

Hello, if that's just for sound on wall collision i would suggest to link a simple box on top of the car :
(warning : butchered example)

PunBB bbcode test

Then in script :

bbox = getObject("bbox")
Sound0 = getObject("Sound0")

soundplay = 0

-- scene update
function onSceneUpdate()

    bboxcoll = getNumCollisions(bbox)

    if bboxcoll >= 2 then -- you might have to change value here
        if soundplay == 0 then
            playSound(Sound0)
        end
        soundplay = 1
    else
        soundplay = 0
    end
end

Hope it helps