; ResetEntity Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-6 light=CreateLight() RotateEntity light,45,45,0 ; Spheres (type 1) collide with and slide off walls (type 2) Collisions 1,2,2,2 player=CreateSphere(16) ScaleEntity player,0.5,0.5,0.5 EntityRadius player,0.5 EntityType player,1 EntityColor player,0,255,100 wall=CreateCube() ScaleEntity wall,3,3,0.25 PositionEntity wall,0,0,3 EntityType wall,2 EntityColor wall,255,60,60 use_reset=1 While Not KeyDown(1) ; Arrow keys drive the sphere (up/down = towards/away from the wall) If KeyDown(203) Then MoveEntity player,-0.1,0,0 If KeyDown(205) Then MoveEntity player,0.1,0,0 If KeyDown(200) Then MoveEntity player,0,0,0.1 If KeyDown(208) Then MoveEntity player,0,0,-0.1 ; Space teleports the sphere to the far side of the wall If KeyHit(57) PositionEntity player,0,0,6 ; ResetEntity clears the collision state, so the jump is not treated ; as movement THROUGH the wall. Press R to turn it off and watch the ; collision system drag the sphere back to the wall instead. If use_reset Then ResetEntity player EndIf ; R toggles whether ResetEntity is used after the teleport If KeyHit(19) Then use_reset=1-use_reset UpdateWorld RenderWorld Text 0,0,"Arrows: drive Space: teleport past wall R: toggle ResetEntity Esc: exit" If use_reset Text 0,20,"ResetEntity ON - the teleport succeeds cleanly" Else Text 0,20,"ResetEntity OFF - the wall blocks the teleport" EndIf Flip Wend End