# Physiycs.body EDGE .position?

Hello. Im confused about what .position does for an EDGE physics body. Its a vec2 and not a vec4 which seems odd especially when you set the original pos in 2 vec2s. Can someone please alleviate my confusion?

@Goatboy76 - I’m guessing position doesn’t do anything for an EDGE, and you should just ignore it.

@Goatboy76 take the position as an average of both vec2s?

@Ignatz I know that it does soemthing because when I set it the EDGE is not where it used to be vs if I dont set the position.

@Goatboy76 - maybe that’s true, but why on earth are you setting position for EDGE? Just ignore it. It’s meant to be used by other physics objects like circles.

@Luatee That would work to get that pos, but to set it? Why not let the user average it instead of bottle necking it there.

@Ignatz Im probley using the wrong type. EDGEs aren’t meant to be moved? I wanting to have a “wall” that moves along a set path. Would chain be better?

Use a thin rectangle polygon instead of an edge to move it

@Coder Good idea

I tried to wright an example of @Coder 's idea, but I’ve hit the same speed bump as before.
I cant find a way to get the pos of the rect. I feel like I’ve been down this road before but I probley deleted my example.

The block stops at -461 which makes me think that it is hitting the “floor” at the bottom of the screen and the starting pos for drawing it is wrong. But when I translate the drawing to the startingPos and it doesn’t quite line up.
Can someone please explain what is going on?

``````function setup()
f1 = vec2(0,0)
f2 = vec2(WIDTH,0)
floor = physics.body(EDGE,f1,f2)

rw1 = vec2(WIDTH,0)
rw2 = vec2(WIDTH,HEIGHT)
rw = physics.body(EDGE,rw1, rw2)

lw1 = vec2(0,0)
lw2 = vec2(0,HEIGHT)
lw = physics.body(EDGE,lw1, lw2)

c1 = vec2(WIDTH, HEIGHT)
c2 = vec2(0,HEIGHT)
c = physics.body(EDGE,c1, c2)

w = 100
local pos = vec2(WIDTH/2, HEIGHT/2)
rec = physics.body(POLYGON, vec2(pos.x - w/2, pos.y - w/2), vec2(pos.x + w/2, pos.y - w/2),
vec2(pos.x - w/2, pos.y + w/2), vec2(pos.x + w/2,pos.y + w/2))
rec.type = DYNAMIC

-- rec.type = STATIC
-- rec.position = vec2(pos.x, pos.y)
print(rec.position)

end

function draw()
print(rec.position)
background(40, 40, 50)

fill(224, 26, 26, 255)
local pos = rec.position
--  translate(startPos.x, startPos.y)
rect(pos.x, pos.y, w, w)

end
``````

Add WIDTH/2 and HEIGHT/2 to the pos in rect()

@Luatee Do you know why the rect stops short of the bottom and kind gitters when it stops?

@Goatboy76 Try this.

``````
function setup()
rectMode(CENTER)
f1 = vec2(0,0)
f2 = vec2(WIDTH,0)
floor = physics.body(EDGE,f1,f2)

rw1 = vec2(WIDTH,0)
rw2 = vec2(WIDTH,HEIGHT)
rw = physics.body(EDGE,rw1, rw2)

lw1 = vec2(0,0)
lw2 = vec2(0,HEIGHT)
lw = physics.body(EDGE,lw1, lw2)

c1 = vec2(WIDTH, HEIGHT)
c2 = vec2(0,HEIGHT)
c = physics.body(EDGE,c1, c2)

w = 100
local pos = vec2(WIDTH/2, HEIGHT/2)
rec = physics.body(POLYGON, vec2(-w/2,-w/2),vec2(w/2,-w/2),
vec2(w/2,w/2), vec2(-w/2,w/2))

rec.x=300
rec.y=600
end

function draw()
print(rec.position)
background(40, 40, 50)

fill(224, 26, 26, 255)
--local pos = rec.position
--  translate(startPos.x, startPos.y)
rect(rec.x,rec.y, w, w)
end

``````

@dave1707 Thanks for your help. My mistake was not knowing you set the points with the origin at the pos. Thanks eveyone!

@Goatboy76 Depending on whether you want the reference at a corner or the center of the rect, it’s easier do it using the origin.