|
entity - live 3D entity pitch - True locks rotation about X yaw - True locks rotation about Y roll - True locks rotation about Z |
|
Stops a dynamic entity rotating about chosen axes. Use it for a barrel that may roll but never tip over, or a pushable crate that should stay upright. All locks are initially False. Locked angular velocity components are cleared, but locks do not prevent explicit RotateEntity teleports. The setting can be stored before enrollment; an active Collisions-controlled mover rejects it because the controller owns its upright locks. Locking rotation does not make a complete character controller. For the full story, see the entity-physics guide, or browse the compact command set. See also: EntityPhysics, EntityVelocity, RotateEntity. |
; EntityRotationLock Example
; --------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
; Entity physics runs on the Box3D collision backend
SetCollisionBackend 1
Const SCENERY=1
Const PROPS=2
camera=CreateCamera()
PositionEntity camera,0,3,-10
RotateEntity camera,10,0,0
light=CreateLight()
RotateEntity light,45,-25,0
AmbientLight 80,80,90
; A static floor for the crate to land on
ground=CreateCube()
ScaleEntity ground,10,0.5,10
PositionEntity ground,0,-0.5,0
EntityColor ground,65,85,100
EntityType ground,SCENERY
EntityPhysics ground,0
; A dynamic crate that falls and settles on its own
crate=CreateCube()
ScaleEntity crate,0.5,0.5,0.5
PositionEntity crate,0,4,0
RotateEntity crate,30,0,25
EntityColor crate,235,155,65
EntityType crate,PROPS
EntityPhysics crate
; Props collide physically with the scenery
Physics PROPS,SCENERY
locked=False
timer=CreateTimer(60)
While Not KeyDown(1)
; Space toggles all three rotation locks, then R drops the tilted crate again
If KeyHit(57) Then locked=Not locked
EntityRotationLock crate,locked,locked,locked
; R drops the crate again
If KeyHit(19)
PositionEntity crate,0,4,0
RotateEntity crate,30,0,25
ResetEntity crate
EndIf
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
UpdateWorld
RenderWorld
Text 0,0,"Arrow keys: move camera Space: toggle locks R: drop again Esc: exit"
Text 0,20,"EntityRotationLock crate,"+locked+","+locked+","+locked+" (locked, it cannot tip over)"
Flip
WaitTimer timer
Wend
End