Jump to content

MaD2ko0l

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by MaD2ko0l

  1. Hey, Try this script to give you an idea: http://www.leadwerks.com/werkspace/files/file/405-freelooklua/ it did exactly what i needed.
  2. 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
  3. MaD2ko0l

    Shooting

    Hi, New to LUA and programming. I have made a top down view scroller and i have got the basic controls working how i want them, however, i am a stuck with the shooting aspect and dont really know where to look. the FPSPlayer/FPSWeapon lua isnt really helping me understand. what i am after is when you click the mouse i want it to shoot a small laser beam from 2 points on the ship and simply move in a straight line and off the screen unless it hits and enemy. Can someone point me in the right direction or know of a tutorial or something? Regards, Martin
×
×
  • Create New...