So what I'm wanting is for him to face the cliff while he's scaling it...the way it is, as you'll see, he just flips around when you hit the button.
Graphics3D 800,600
SetBuffer BackBuffer()
camera=CreateCamera()
CameraViewport camera,0,0,800,600
light=CreateLight()
Global cube
Global cone
Global land
Global cliff
Global cube_col = 2
Global land_col = 3
Global cliff_col = 4
Global alignment% = 1
Collisions cube_col, land_col, 2, 2
Collisions cube_col,cliff_col, 2, 2
cube=CreateCube()
EntityType cube, cube_col, False
EntityColor cube, 0, 80, 150
EntityRadius cube, 1.5, 1.5
PositionEntity cube, 0, 0, 10
cone=CreateCone()
PositionEntity cone, 0, 0, 13
EntityColor cone, 0, 80, 150
RotateEntity cone, 90, 0, 0
ScaleEntity cone, 1, 2, 1
EntityParent cone, cube
land=CreatePlane()
EntityPickMode land, 2
EntityType land, land_col, True
PositionEntity land, 0, -10, 0
RotateEntity land, 0, 0, -15
EntityColor land, 100, 170, 50
cliff=CreateCube()
EntityPickMode cliff, 2
ScaleEntity cliff, 10, 40, 10
EntityType cliff, cliff_col, True
RotateEntity cliff, 0, 10, -15
PositionEntity cliff, 10, 0, 40
EntityColor cliff, 80, 80, 80
While Not KeyHit(1)
If KeyDown(17) = True Then
MoveEntity cube, 0, 0, .5
EndIf
If KeyDown(31) = True Then
MoveEntity cube, 0, 0, -.5
EndIf
If KeyDown(30) = True Then
TurnEntity cube, 0, 3, 0
EndIf
If KeyDown(32) = True Then
TurnEntity cube, 0, -3, 0
EndIf
If KeyDown(2) = True Then
alignment = 1
EndIf
If KeyDown(3) = True Then
alignment = 2
EndIf
TFormVector 0, 0, 3, cube, 0
LinePick(EntityX(cube,True),EntityY(cube,True),EntityZ(cube,True),TFormedX(),TFormedY(),TFormedZ())
If PickedEntity() = cliff Then
If KeyDown(4) = True Then
alignment = 3
EndIf
EndIf
If alignment = 1 Then
LinePick EntityX(cube), EntityY(cube), EntityZ(cube), 0, -1, 0, 1
If PickedEntity() <> land Then
TranslateEntity cube, 0, -.5, 0
EndIf
EndIf
If alignment = 2 Then
TFormVector 0, 1.5, 0, cube, 0
LinePick(EntityX(cube,True),EntityY(cube,True),EntityZ(cube,True),TFormedX(),TFormedY(),TFormedZ())
AlignToVector cube,PickedNX(),PickedNY(),PickedNZ(),2,0.1
LinePick EntityX(cube), EntityY(cube), EntityZ(cube), 0, -1, 0, 1
If PickedEntity() <> land Then
TranslateEntity cube, 0, -.5, 0
EndIf
EndIf
If alignment = 3 Then
TFormVector 0, 0, 1.5, cube, 0
LinePick(EntityX(cube,True),EntityY(cube,True),EntityZ(cube,True),TFormedX(),TFormedY(),TFormedZ())
AlignToVector cube,PickedNX(),PickedNY(),PickedNZ(),3,0.1
EndIf
UpdateWorld
RenderWorld
Text 150,500,"WASD for movement"
Text 150,515,"Press 1 for normal alignment"
Text 150,530,"Press 2 for ground alignment"
Text 150,545,"Press 3 while facing and close to cliff for cliff alignment"
Flip
Wend
End
|