Hi, I've been working on some collision for my game for more than 2 days now and I'm clueless
.
I am trying to make some smooth sliding collision and I looked at some examples in the codebase.
The code I use is given below and everytime it collides and thus gets repositioned, it ALWAYS moves back to the point 0,0,0 and I have no clue why.
Note: ObjPosX#, ObjPosY# and ObjPosZ# are the old object positions, CurX#, CurY# and CurZ# are the new object positions.
function Collision(Object#,Target#)
`Store current object positions
CurX#=object position x(1)
CurY#=object position y(1)
CurZ#=object position z(1)
if object collision(Object#,Target#) <> 0
position object Object#, ObjPosX#, CurY#, CurZ#
if object collision(Object#,Target#)<>0
Position object Object#, CurX#, CurY#, ObjPosZ#
If Object Collision(Object#,Target#)<>0
Position Object Object#, CurX#, ObjPosY#, CurZ#
If Object Collision(Object#,Target#)<>0
CurY# = ObjPosY#
CurX# = ObjPosX#
CurZ# = ObjPosZ#
Else
CurY# = ObjPosY#
EndIf
Else
CurZ# = ObjPosZ#
EndIf
else
CurX# = ObjPosX#
endif
EndIf
position object Object#, CurX#, CurY#, CurZ#
endfunction
If anyone has any idea why this code does not work properly, please help me out and tell me why
To subdue the enemy without fighting is the highest skill...