Wrong EntityDirectionX/Y/Z()
Posted: Sat Jun 15, 2024 5:45 pm
Look at this; play pressing right and left arrow keys.
It always returns the same 'Entitydirection'
ADDENDUM:
And playing with this one is even more fun (need explanation
):
And with EntityYaw(), which always returns 0
:
It always returns the same 'Entitydirection'

Code: Select all
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"v",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,10,#PB_Absolute)
Createcone(0,1,2):CreateEntity(0,MeshID(0),#PB_Material_None)
Repeat
Repeat:Eventodeventana.i=WindowEvent():Until Eventodeventana=0
ExamineKeyboard()
if KeyboardReleased(#PB_Key_left):Roll(EntityID(0),90,#PB_Absolute|#PB_World)
elseif KeyboardReleased(#PB_Key_right):Roll(EntityID(0),-90,#PB_Absolute|#PB_World)
endif
debug strf(EntityDirectionX(0),2)+","+Strf(EntityDirectionY(0),2)+","+StrF(EntityDirectionZ(0),2)
RenderWorld()
FlipBuffers():Delay(16)
Until KeyboardPushed(#PB_Key_Escape)
And playing with this one is even more fun (need explanation

Code: Select all
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"v",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,10,#PB_Absolute)
Createcone(0,1,2):CreateEntity(0,MeshID(0),#PB_Material_None)
Repeat
Repeat:Eventodeventana.i=WindowEvent():Until Eventodeventana=0
ExamineKeyboard()
if KeyboardReleased(#PB_Key_left):EntityDirection(0,-1,0,0,#PB_World,#PB_Vector_Y)
elseif KeyboardReleased(#PB_Key_right):EntityDirection(0,1,0,0,#PB_World,#PB_Vector_Y)
endif
debug strf(EntityDirectionX(0),2)+","+Strf(EntityDirectionY(0),2)+","+StrF(EntityDirectionZ(0),2)
RenderWorld()
FlipBuffers():Delay(16)
Until KeyboardPushed(#PB_Key_Escape)

Code: Select all
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"v",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,10,#PB_Absolute)
Createcone(0,1,2):CreateEntity(0,MeshID(0),#PB_Material_None)
Repeat
Repeat:Eventodeventana.i=WindowEvent():Until Eventodeventana=0
ExamineKeyboard()
if KeyboardReleased(#PB_Key_left):EntityFixedYawAxis(0,1,0,0,1):Yaw(EntityID(0),90,#PB_World|#PB_Absolute)
elseif KeyboardReleased(#PB_Key_right):EntityFixedYawAxis(0,1,0,0,-1):Yaw(EntityID(0),90,#PB_World|#PB_Absolute)
endif
debug EntityYaw(0,#PB_Absolute|#PB_Engine3D_Raw)
RenderWorld()
FlipBuffers():Delay(16)
Until KeyboardPushed(#PB_Key_Escape)