Jump to content

moving object via keyboard


drarem
 Share

Recommended Posts

I want to create a model like a car, attach camera to it and move the car/camera around. I would like the camera slightly above the roof of the car. What's the best way to do that? I played around with the FPS controller until my brain hurt. version 3.3 w/Lua

 

Thanks.

Link to comment
Share on other sites

I assigned this script to my camera->Object, but it doesn't seem to move.

 

 

Script.window = Window:GetCurrent()

Script.move = Vec3()

function Script:Start()

self.rotation = self.entity:GetRotation()

self.entity:SetFriction(0,0)
self.move = Vec3(0,0,0)
end




function Script:UpdatePhysics()

self.move = Vec3(0,0,0)

local movespeed= 10
if (self.window:KeyDown(Key.Up)) then self.move.x= movespeed * Time:GetSpeed() end
if (self.window:KeyDown(Key.Down)) then self.move.x= -1 * movespeed * Time:GetSpeed() end

self.entity:AddForce(self.move.x,0,self.move.z)

Time:Update()
end

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...