# How do i stop my static cube from going through walls?

Guys I need your help, I am making a game where the cube is the player which is static ( IT IS COMPULSORY FOR IT TO BE STATIC) and it has to pass throught various blocks coming from front of it, and I want the cube to collide with other static objects, please tell me how to do this?

player NPC and monsters are not static objects they need physics, so setting them to static is kind of dumb, use something more useful like character physics or dynamic.

Or roll out your own physics like I did. Absolutely not performant. Go with dynamics, you silly.

But if you MUST go with statics, here, wrap your head around this. I am not going to explain it, so donâ€™t ask.

``````	def moveClamp(self, vec):
vol = self.cullingBox.max

xdirn = -1 if vec[0] < 0 else 1 if vec[0] > 0 else 0
ydirn = -1 if vec[1] < 0 else 1 if vec[1] > 0 else 0
zdirn = -1 if vec[2] <= 0 else 1

f = 2

if vec[0]:

for i, y_offset in enumerate([ 0, vol[1], -vol[1], 0, 0 ]):

lpos = self.worldPosition + (self.worldOrientation.col[0]
*(vol[0]*(f+(0.5 if not i else 0))*xdirn))

lpos = lpos + (self.worldOrientation.col[1]*(vol[1]*f*y_offset))

z_offset = 0
if i == 3: z_offset = -(vol[2]/3)
elif i == 4: z_offset = vol[2]/3

vecTo = [ lpos[0], lpos[1],
self.worldPosition.z+(vol[2]/2)+z_offset ]

vecFrom = [ self.worldPosition.x, self.worldPosition.y,
self.worldPosition.z+vol[2]/2 ]

if physDebug: drawLine(vecTo, vecFrom, [1,0,0])

if xclip_ray[0]:
dist = self.getDistanceTo(xclip_ray[1])
if dist < f:
vec[0] = abs(vec[0]/3)*-xdirn
self.accel.x = 0
else:
vec[0] = 0
self.accel.x = 0
"""
if not self.isClimbing:
if xdirn == -1: rr = -rr
rot = [0,0,rr]

self.climbCheck(xclip_ray, rot)
"""

break

if vec[1]:
obsDirn = {vol[0]:0, -vol[0]:0, 0:0}
checkObs = False
for i, x_offset in enumerate([0, vol[0], -vol[0], 0, 0 ]):

lpos = self.worldPosition + (self.worldOrientation.col[1]
*(vol[1]*(f+(0.5 if not i else 0))*ydirn))
lpos = lpos + (self.worldOrientation.col[0]*(vol[0]*f*x_offset))

z_offset = 0
if i == 3: z_offset = -(vol[2]/3)
elif i == 4: z_offset = vol[2]/3

vecTo = [ lpos[0], lpos[1],
self.worldPosition.z+(vol[2]/2)+z_offset ]

vecFrom=[ self.worldPosition.x, self.worldPosition.y,
self.worldPosition.z+(vol[2]/2) ]

if physDebug: drawLine(vecTo, vecFrom, [0,1,0])

if yclip_ray[0]:
dist = self.getDistanceTo(yclip_ray[1])
if dist < f:
vec[1] = abs(vec[1]/3)*-ydirn
self.accel.x = 0
else:
vec[1] = 0
self.accel.y = 0

if ydirn == -1 and i == 0:
if "climb" in yclip_ray[0] and not z_offset:

if ((not self.isClimbing)
and (self.isJumping or not self.isOnGround)):
self.climbCheck(yclip_ray)

break

if vec[2]:
l = [ [0,0], [ vol[0], 0 ],
[ -vol[0], 0 ], [ 0, vol[1] ], [ 0, -vol[1] ] ]
f = self.accel.z if not self.isOnGround else f
for xy_offset in l:

lpos = self.worldPosition + (self.worldOrientation.col[0]
*(vol[0]*xy_offset[0] ))

lpos += self.worldOrientation.col[1]*(vol[1]*xy_offset[1] )

vecTo = [ lpos[0], lpos[1], lpos[2]+(f*zdirn)
-(vol[2]/5 if zdirn < 0 else -vol[2]/1.4) ]

vecFrom = [ lpos[0], lpos[1], lpos[2]+(vol[2]/2) ]

if physDebug: drawLine(vecTo, vecFrom, [0,0,1])

zclip_ray = self.rayCast( vecTo, vecFrom, xray=True,

if zclip_ray[0]:
vol2 = zclip_ray[0].cullingBox.max[2]
dist = self.getDistanceTo(zclip_ray[1])

if not self.isJumping or zdirn == 1:
self.accel.z = vec[2] = 0
if zdirn == 1:
self.isJumping = False
self.arma.onAnimChange(0, "idleAir")

else: self.worldPosition.z = zclip_ray[1][2]

break

return vec
``````