Added better control to the MainScene's camera

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2021-06-09 19:51:03 +02:00
parent 134081166e
commit a9f4459e63
2 changed files with 7 additions and 6 deletions

View File

@@ -9,22 +9,24 @@ this.on_update = function()
local deltaMouseMovement = Input.getDeltaMousePos()
this.angles.y = this.angles.y - deltaMouseMovement.x * this.mouse_sens
this.eulerAngles = this.angles
print('Camera OnUpdate')
if Input.getKeyJustPressed(Input.KeyCode.Enter) then
gotoScene('SideScene')
end
local pos = this.position
if Input.getKeyDown(Input.KeyCode.Up) then
this.position = this.position + this:getChild('RotationHelper').forward * this.speed
pos = pos + this:getChild('RotationHelper').forward * this.speed
end
if Input.getKeyDown(Input.KeyCode.Down) then
this.position = this.position - this:getChild('RotationHelper').forward * this.speed
pos = pos - this:getChild('RotationHelper').forward * this.speed
end
if Input.getKeyDown(Input.KeyCode.Right) then
this.position = this.position + Vec3:new(1, 0, 0) * this.speed
pos = pos + this:getChild('RotationHelper').right * this.speed
end
if Input.getKeyDown(Input.KeyCode.Left) then
this.position = this.position - Vec3:new(1, 0, 0) * this.speed
pos = pos - this:getChild('RotationHelper').right * this.speed
end
this.position = pos
end

View File

@@ -7,5 +7,4 @@ this.on_update = function()
local deltaMouseMovement = Input.getDeltaMousePos()
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
this.eulerAngles = this.angles
print('CameraHelper OnUpdate')
end