Setting boundaries for KINEMATIC bodies.

I want to know if there is a way to allow KINEMATIC bodies to be stopped by certain STATIC bodies so that I could have a body within boundaries that is at the same time not able to be pushed around by any other physics bodies. If this is simply not possible, I would like to know if you could instead make DYNAMIC bodies ignore certain physics bodies (but still stop them upon collision) for a similar outcome.

@Paintcannon Lookup catagories and masks for physics bodies in the documentation. Those can be used to alter what bodies collide. Not sure if that’s what you’re after.

The best I could find was a rope (Physics Joint) but the rope when tied to the kinematic object and a static object does not pull or constrain either of them. I need some way to make sure that kinematic bodies don’t go off screen.

I think what @Dave1707 meant is to use Dynamic bodies instead of Kinematic ones, and set their phasing category so they phase through most objects like Kinematics but can collide with others.

But I don’t want them to phase through other bodies, I want DYNAMIC bodies to be able to collide with them but not in any way affect them.

A DYNAMIC body can collide with a STATIC body and the STATIC body won’t be affected. Can you give a detailed description of what you want to happen.

I want to have kinematic bodies in my game while making sure that they don’t go off screen. It’s as simple as that, yet for this I need to be able to make some sort of boundary that will stop them.

In that case, since kinematic bodies will be moving around, just check their x,y values and don’t let them move off the screen. If your moving them with linearVelocity, set their velocity to 0. If they’re moving by touch, don’t move them off screen.

@dave1707 I’ll look into that. Thank you.

@Paintcannon Here’s an example using Gravity and linearVelocity.

displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT)

function setup()
    b3=physics.body(CIRCLE,50)
    b3.x=250
    b3.y=600
    b3.type=KINEMATIC
end

function draw()
    background(40,40,50)
    fill(255)
    b3.linearVelocity=vec2(Gravity.x*100,Gravity.y*100)
    if b3.x<=50 then
        b3.x=50
    end
    if b3.x>=WIDTH-50 then
        b3.x=WIDTH-50
    end
    if b3.y<=50 then
        b3.y=50
    end
    if b3.y>=HEIGHT-50 then
        b3.y=HEIGHT-50
    end
    ellipse(b3.x,b3.y,100)
end