Proximity sensor detection

Typically: "How do I... ", "How can I... " questions
Post Reply
pps
Posts: 4
Joined: 13 Feb 2019, 16:03

Proximity sensor detection

Post by pps »

Hello,

is there a way how to recognize if object detected by proximity sensor is static or dynamic?

Thanks!

coppelia
Site Admin
Posts: 10362
Joined: 14 Dec 2012, 00:25

Re: Proximity sensor detection

Post by coppelia »

Hello,

yes, you can do:

Code: Select all

local result,distance,detectedPoint,detectedObjectHandle,detectedSurfaceNormalVector=sim.readProximitySensor(sensorHandle)
if detectedObjectHandle then
    if sim.getObjectType(detectedObjectHandle)==sim.object_shape_type then
        local r,p=sim.getObjectInt32Parameter(detectedObjectHandle,sim.shapeintparam_static)
        if p>0 then
            print("detected static shape")
        else
            print("detected dynamic shape")
        end
    end
end
Cheers

Post Reply