I was suprized to find out that there is no examples on how to push objects around like in tomb raider, or resident evil. like when they move blocks or pillars and stuff. If anyone would like to help me with this code I will post it in the code base. Here is what I have so far. A sphere and a cube; player controls sphere with keys w,s,a and d;
What I want to happen is when sphere collides with box (for example from the top of the cube, the cube should move down)or vise versa. I think I need to use the comands collision x,y,z but not sure how to do that.
Another way I tried is if sphere is to check if sphere is higher or lower, to the right of or to the left of box at time of collision, so that box would move acordingly.
Do I at least have a clue?
Graphics3D 640,480,16
SetBuffer BackBuffer()
Const cube_col=1
Const sphere_col=2
light= CreateLight()
camera=CreateCamera()
PositionEntity camera,0,40,0
Type cubedata
Field x#,y#
End Type
Type circledata
Field x#,y#
End Type
box.cubedata = New cubedata
box\x#=-10
box\y#=40
cube= CreateCube()
ScaleEntity cube,1,2,2
PositionEntity cube,box\x#,box\y#,20
EntityColor cube,255,0,0
EntityType cube,cube_col;colitionccccccccccccccccccccccccccccc
;EntityBox entity,x#,y#,z#,width#,height#,depth#
EntityBox cube,-10,40,20,1,2,2
;CollisionX# ( entity,index )
;CollisionX# ( cube,1 )
;CollisionY# ( cube,1 )
;player
circle.circledata = New circledata
circle\x#=10
circle\y#=40
sphere= CreateSphere()
EntityColor sphere,0,0,255
PositionEntity sphere,circle\x#,circle\y#,20
EntityType sphere,sphere_col;colitionccccccccccccccccccccccccccccc
Collisions sphere_col,cube_col,2,3
Global rsx#=-.25
Global lsx#=.25
Global rsy#=-.25
Global lsy#=.25
While Not KeyHit(1)
If KeyDown(30) MoveEntity sphere,rsx#,0,0
If KeyDown(32) MoveEntity sphere,lsx#,0,0
If KeyDown(17) MoveEntity sphere,0,lsy#,0
If KeyDown(31) MoveEntity sphere,0,rsy#,0
UpdateWorld()
RenderWorld()
Text 10,20,circle\x + circle\y
If EntityCollided(sphere,cube_col)
Text 370,80,"Collided !!!"
TranslateEntity cube,-.25+(bx#*2),0,0
EndIf
Text 335,500,"Collision Detection"
Flip
Wend
End
What I want to happen is when sphere collides with box (for example from the top of the cube, the cube should move down)or vise versa. I think I need to use the comands collision x,y,z but not sure how to do that.
Another way I tried is if sphere is to check if sphere is higher or lower, to the right of or to the left of box at time of collision, so that box would move acordingly.
Do I at least have a clue?
Graphics3D 640,480,16
SetBuffer BackBuffer()
Const cube_col=1
Const sphere_col=2
light= CreateLight()
camera=CreateCamera()
PositionEntity camera,0,40,0
Type cubedata
Field x#,y#
End Type
Type circledata
Field x#,y#
End Type
box.cubedata = New cubedata
box\x#=-10
box\y#=40
cube= CreateCube()
ScaleEntity cube,1,2,2
PositionEntity cube,box\x#,box\y#,20
EntityColor cube,255,0,0
EntityType cube,cube_col;colitionccccccccccccccccccccccccccccc
;EntityBox entity,x#,y#,z#,width#,height#,depth#
EntityBox cube,-10,40,20,1,2,2
;CollisionX# ( entity,index )
;CollisionX# ( cube,1 )
;CollisionY# ( cube,1 )
;player
circle.circledata = New circledata
circle\x#=10
circle\y#=40
sphere= CreateSphere()
EntityColor sphere,0,0,255
PositionEntity sphere,circle\x#,circle\y#,20
EntityType sphere,sphere_col;colitionccccccccccccccccccccccccccccc
Collisions sphere_col,cube_col,2,3
Global rsx#=-.25
Global lsx#=.25
Global rsy#=-.25
Global lsy#=.25
While Not KeyHit(1)
If KeyDown(30) MoveEntity sphere,rsx#,0,0
If KeyDown(32) MoveEntity sphere,lsx#,0,0
If KeyDown(17) MoveEntity sphere,0,lsy#,0
If KeyDown(31) MoveEntity sphere,0,rsy#,0
UpdateWorld()
RenderWorld()
Text 10,20,circle\x + circle\y
If EntityCollided(sphere,cube_col)
Text 370,80,"Collided !!!"
TranslateEntity cube,-.25+(bx#*2),0,0
EndIf
Text 335,500,"Collision Detection"
Flip
Wend
End