Hi,
I was trying to do a similar thing where by i was aiming to do a top down view and move the player via WASD.
here is my code to do this:
import "Scripts/Functions/ReleaseTableObjects.lua"
Script.moveSpeed = 2.5 --float "Move Speed"
Script.input={}
Script.playerMovement = Vec3(0,0,0)
function Script:Start()
--Create a camera
self.camera = Camera:Create()
--Set the camera position
self.camera:SetPosition(0,10,0)
self.camera:SetRotation(90,0,0)
--check to see if player has mass
local mass = self.entity:GetMass()
if self.entity:GetMass()==0 then Debug:Error("Player mass should be greater than 0.") end
end
function Script:UpdatePhysics()
local window = Window:GetCurrent()
--Player Movement
local move = ((window:KeyDown(Key.W) and 1 or 0) - (window:KeyDown(Key.S) and 1 or 0))*4
local strafe = ((window:KeyDown(Key.D)and 1 or 0) - (window:KeyDown(Key.A) and 1 or 0))*4
local playerMovement = Vec3(0)
playerMovement.x = move * self.moveSpeed
playerMovement.z = strafe * self.moveSpeed
self.entity:SetInput(0,playerMovement.x,playerMovement.z)
--Move camera with player
local playerPos = self.entity:GetPosition()
local newCameraPos = self.camera:GetPosition()
newCameraPos = Vec3(playerPos.x, 10, playerPos.z)
self.camera:SetPosition(newCameraPos)
end
i have tried to document what i know to the best of my current knowledge and this may not be the best solution but it works.
to use it, simply
add this script to a model
give the model a mass in the physics tab
set its physics mode to character controller
and you are done
i must admit that when i saw this game engine on steam i thought that there would be more tutorials and and code snippets to use and learn from but i have found that these are somewhat rare to find at the moment and i also find while reading some posts is that there is a certain elitism going on with unhelpful replies such as "learn Lua" and the likes
(sorry....rant over)
I hope this helps
ship-topdown-cammove.lua