Added better control to the MainScene's camera
Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
@@ -9,22 +9,24 @@ this.on_update = function()
|
|||||||
local deltaMouseMovement = Input.getDeltaMousePos()
|
local deltaMouseMovement = Input.getDeltaMousePos()
|
||||||
this.angles.y = this.angles.y - deltaMouseMovement.x * this.mouse_sens
|
this.angles.y = this.angles.y - deltaMouseMovement.x * this.mouse_sens
|
||||||
this.eulerAngles = this.angles
|
this.eulerAngles = this.angles
|
||||||
print('Camera OnUpdate')
|
|
||||||
|
|
||||||
if Input.getKeyJustPressed(Input.KeyCode.Enter) then
|
if Input.getKeyJustPressed(Input.KeyCode.Enter) then
|
||||||
gotoScene('SideScene')
|
gotoScene('SideScene')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local pos = this.position
|
||||||
if Input.getKeyDown(Input.KeyCode.Up) then
|
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
|
end
|
||||||
if Input.getKeyDown(Input.KeyCode.Down) then
|
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
|
end
|
||||||
if Input.getKeyDown(Input.KeyCode.Right) then
|
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
|
end
|
||||||
if Input.getKeyDown(Input.KeyCode.Left) then
|
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
|
end
|
||||||
|
|
||||||
|
this.position = pos
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ this.on_update = function()
|
|||||||
local deltaMouseMovement = Input.getDeltaMousePos()
|
local deltaMouseMovement = Input.getDeltaMousePos()
|
||||||
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
|
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
|
||||||
this.eulerAngles = this.angles
|
this.eulerAngles = this.angles
|
||||||
print('CameraHelper OnUpdate')
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user