STATIC, DYNAMIC, KINEMATIC, oh my!

What type of body is a physics body by default?

After reading the descriptions on how static and kinematic bodies do not collide, why would you ever use them?

All I want is simple collision detection. I want to know when a circle or polygon shape collides with a rectangle shape. What is the most efficient (least amount of calculations to ensure highest frame rate) type to use? Kinematic, dynamic, or static?

Thanks

function setup()
    
    test = PhysicsDebugDraw()
    
    x = WIDTH/2
    y = HEIGHT/2
    
    collision = false
    
    ebody = physics.body(CIRCLE,25)
    ebody.x = x
    ebody.y = y
    -- ebody.type = STATIC
    
    edgeBody = physics.body(EDGE,vec2(WIDTH/1.5,HEIGHT/2),vec2(WIDTH/1.5,HEIGHT/2+100))
    
    -- rbody = physics.body(POLYGON,vec2(WIDTH/1.5,HEIGHT/2),vec2(WIDTH/1.5,HEIGHT/2+100),vec2(WIDTH/1.5+50,HEIGHT/2+100),vec2(WIDTH/1.5+50,HEIGHT/2))
    -- rbody.type = DYNAMIC
    
    -- rbody.restitution = 0
    -- rbody.fixedRotation = true
    -- rbody.sensor = true
    
    test:addBody(ebody)
    -- test:addBody(rbody)
    test:addBody(edgeBody)
    

    
    physics.gravity(0,0)
    
end

function draw()
    background(101, 155, 178, 255)
    ellipse(x,y,50)
    
    if collision == false then
    x = x + 1
    ebody.x = ebody.x + 1
        end
    rect(WIDTH/1.5,HEIGHT/2,50,100)
    
    test:draw()
    
end

function collide(contact)
    if contact.state == BEGAN then
    print("Collision")
        collision = true
        end
    
end

DYNAMIC is the default body type. KINEMATIC and STATIC have collions too.

DYNAMIC has all the calculations for gravity, motion, angles, etc. If all you want is collision detection, KINEMATIC is probably best. KINEMATIC only does collision detection, you set the position manually. They’ye typically used for moving obstacles, or maybe an enemy.

STATIC is motionless, basically a wall.

@SkyTheCoder thanks! The perplexing thing is that if I make both bodies static or kinematic, they pass right through each other and the collide function is never called. It seems like at least one body has to be dynamic.

Kinematic and static bodies only collide with dynamic bodies. Dynamic bodies collide with everything. It is best to move kinematic bodies by setting their linear velocity and/or angular velocity, not by setting their position directly (other than the first time of course).

Basically, kinematic bodies can be thought of as “moving static” bodies, if that makes any sense.