Je cherche à exécuter la fonction MoveEntity() pour déplacer ce cube uniquement si la vitesse est différente de 0.

par contre si je commente ce test (ligne 95), alors je peux déplacer ce cube.
Code : Tout sélectionner
EnableExplicit
Enumeration
#Mainform
EndEnumeration
Global WWIdth, WHeight, Window, Event
Global Camera, Texture, Material, Mesh, Entity
Global Ground, Player, PlayerSpeed.f
InitEngine3D()
InitKeyboard()
InitSprite()
InitMouse()
OpenWindow(#Mainform,0,0, 0, 0, "", #PB_Window_SystemMenu | #PB_Window_Maximize)
WWidth = WindowWidth(#Mainform, #PB_Window_InnerCoordinate)
WHeight = WindowHeight(#Mainform, #PB_Window_InnerCoordinate)
OpenWindowedScreen(WindowID(#Mainform),0,0,WWIdth,WHeight,0, 0, 0)
KeyboardMode(#PB_Keyboard_International)
;
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)
WorldShadows(#PB_Shadow_Additive)
;
; Texture et materiel pour le sol et le cube
Texture = CreateTexture(#PB_Any,512,512)
StartDrawing(TextureOutput(Texture))
Box(0,0,512,512,RGB(0, 0, 0))
Box(1,1,510,510,RGB(255, 216, 0))
StopDrawing()
Material = CreateMaterial(#PB_Any,TextureID(texture))
;
; Création du sol
Mesh = CreatePlane(#PB_Any, 20, 20, 3, 6, 6, 6)
Ground = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 0, 0)
EntityPhysicBody(Ground, #PB_Entity_StaticBody, 2, 0, 1)
;
; Creation du cube avatar
Mesh = CreateCube(#PB_Any, 1)
Player = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 2, 0)
EntityPhysicBody(Player, #PB_Entity_BoxBody, 10,2,2)
;
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -40, 4, 0)
WorldShadows(#PB_Shadow_Additive)
;
; et enfin une camera
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(145, 182, 201))
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
If ExamineKeyboard()
If KeyboardPushed (#PB_Key_Escape)
Break
EndIf
EndIf
;Rotation & gauche ou à droite
If KeyboardPushed (#PB_Key_Left)
RotateEntity(Player, 0, 1.5, 0, #PB_Relative)
ElseIf KeyboardPushed (#PB_Key_Right)
RotateEntity(Player, 0, -1.5, 0, #PB_Relative)
EndIf
;En avant ou en arriére
If KeyboardPushed (#PB_Key_Up)
PlayerSpeed = 1.5
ElseIf KeyboardPushed (#PB_Key_Down)
PlayerSpeed = - 1.5
Else
PlayerSpeed = 0
EndIf
;Mouvement du joueur
If PlayerSpeed <> 0
MoveEntity(Player, 0, 0, PlayerSpeed, #PB_Absolute|#PB_Local)
EndIf
;CamearaFollow (PB 5.20) permet de suivre le joueur
CameraFollow(Camera, EntityID(Player), 180, EntityY(Player) + 3, 6, 0.05, 0.05, #True)
; Affiche le rendu de la scéne
RenderWorld(80)
FlipBuffers()
ForEver
