Playertest first pass

This commit is contained in:
2026-04-21 08:39:50 -05:00
parent 7c3386cf3e
commit 17c924f040
43 changed files with 1701 additions and 727 deletions
+46
View File
@@ -0,0 +1,46 @@
module('entity')
module('input')
module('color')
module('math')
module('scene')
module('event')
module('entitycamera')
local phys
local updateSub
local SPEED = 4.0
function entityInit()
local pos = entityPositionAdd(ENTITY_ID)
pos.x = 0
pos.y = 1
pos.z = 0
phys = entityPhysicsAdd(ENTITY_ID)
phys:setShapeCapsule(0.3, 0.9)
local mesh = entityMeshAdd(ENTITY_ID)
mesh:generateCapsule(0.3, 0.9)
local mat = entityMaterialAdd(ENTITY_ID)
mat.color = colorBlue()
updateSub = eventSubscribe(SCENE_EVENT_UPDATE, onUpdate)
end
function onUpdate()
local moveX = inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT)
local moveZ = inputAxis(INPUT_ACTION_DOWN, INPUT_ACTION_UP)
local cam = entityCameraGetCurrent()
local fwd = cam:getForward()
local right = cam:getRight()
local vy = phys.velocityY
phys.velocityX = (moveX * right.x + moveZ * fwd.x) * SPEED
phys.velocityZ = (moveX * right.y + moveZ * fwd.y) * SPEED
end
function entityDispose()
eventUnsubscribe(SCENE_EVENT_UPDATE, updateSub)
end