Hey, thanks for the answer. What i want to achieve are just platforms i could build a level with but with collision for the player and they have to be static, like floating in the "air" so the player could walk on them.
I upload a video where i try to show my issue as best as possible.
Heres the code for the player
Script.CamOffset = Vec3() --vec3 "Camera Offset"
Script.PlayerMoveSpeed = 5 --float "Player Movement Speed"
--[[Script.isOnFloor = true]]
function Script:Start()
PlayerPos = self.entity:GetPosition()
camera1 = Camera:Create()
camera1:SetPosition(PlayerPos.x, PlayerPos.y + self.CamOffset.y ,PlayerPos.z - self.CamOffset.z)
end
--[[
function Script:UpdateWorld()
end
]]
--[[
function Script:IsOnFloor()
if isOnFloor(true) then
self.entity:SetGravityMode(false)
elseif isOnFloor(false) then
self.entity:SetGravityMode(true)
end
end
]]
function Script:UpdatePhysics()
local CamPosUpdate = self.entity:GetPosition()
camera1:SetPosition(CamPosUpdate.x, CamPosUpdate.y + self.CamOffset.y, CamPosUpdate.z - self.CamOffset.z)
if window:KeyDown(Key.D) then
self.entity:Move(self.PlayerMoveSpeed,0,0)
elseif window:KeyDown(Key.A) then
self.entity:Move(-self.PlayerMoveSpeed,0,0)
end
--[[if self.entity:GetKeyValue("Collision Type","Prop") then
isOnFloor = true
else
isOnFloor = false
end]]
end
The isOnFloor stuff was just me trying something out. Below is the script i attached to one of the boxes in the video to kinda "keep it in place" every physics update, but that causes more headache tbh.
Script.gravitymode = false --bool "Gravity Mode"
function Script:Start()
if self.gravitymode then
self.entity:SetGravityMode(true)
else
self.entity:SetGravityMode(false)
end
PosLock = self.entity:GetPosition()
RotLock = self.entity:GetRotation()
self.entity:SetMass(2)
end
--[[
function Script:UpdateWorld()
end
]]
function Script:UpdatePhysics()
self.entity:SetPosition(PosLock.x, PosLock.y, PosLock.z)
self.entity:SetRotation(RotLock.x, RotLock.y, RotLock.z)
end
1609157828_2022-03-3013-31-06.mkv