This is my code. Entity is not moving at all even with friction 0. Entity has collision box and shape box.
Script.camPos=Vec3()
Script.entPos=Vec3()
Script.camRotation=Vec3()
Script.mouseSensitivity = 15
Script.mouseDifference=Vec2()
Script.mouseOld=Vec2()
Script.currentMousePos=Vec2()
Script.mousepos=Vec2(0,0)
function Script:Start()
local window = Window:GetCurrent()
local context = Context:GetCurrent()
self.camera = Camera:Create()
self:UpdateCamera()
self.entity:SetFriction(1,1)
end
function Script:UpdateCamera()
local context = Context:GetCurrent()
local window = Window:GetCurrent()
self.currentMousePos = window:GetMousePosition()
window:SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2))
self.currentMousePos.x = Math:Round(self.currentMousePos.x)
self.currentMousePos.y = Math:Round(self.currentMousePos.y)
self.mouseDifference.x = Math:Curve(self.currentMousePos.x - Math:Round(context:GetWidth()/2),self.mouseDifference.x,3)
self.mouseDifference.y = Math:Curve(self.currentMousePos.y - Math:Round(context:GetHeight()/2),self.mouseDifference.y,3)
self.camRotation.x = Math:Clamp(self.camRotation.x + self.mouseDifference.y / self.mouseSensitivity,-90,90)
self.camRotation.y = self.camRotation.y + (self.mouseDifference.x / self.mouseSensitivity)
self.camera:SetRotation(self.camRotation)
self.entPos=self.entity:GetPosition()
self.camera:SetPosition(self.entPos.x,self.entPos.y+1.8,self.entPos.z)
self.entity:SetRotation(0,self.camRotation.y,0)
end
function Script:UpdateWorld()
self:UpdateCamera()
end
function Script:UpdatePhysics()
--Get the game window
local window = Window:GetCurrent()
self.entity:SetFriction(1,1)
if window:KeyDown(Key.W) then self.entity:SetVelocity(0,0,10,false) end
--if window:KeyDown(Key.W) then self.entity:AddForce(0,0,10,false) end
--if window:KeyDown(Key.A) then self.entity:AddForce(-speed,0,0,false) end
--if window:KeyDown(Key.D) then self.entity:AddForce(speed,0,0,false) end
--if window:KeyDown(Key.S) then self.entity:AddForce(0,0,-speed,false) end
end