35 lines
1.0 KiB
Lua
35 lines
1.0 KiB
Lua
local Engine = require("./assets/scripts/engine")
|
|
|
|
|
|
local transform = nil
|
|
|
|
local new_rotation = 0
|
|
|
|
local new_rotationSpeed = 15
|
|
|
|
function OnInit()
|
|
local gameObject = Engine.GetGameObjectByTag("Camera")
|
|
transform = gameObject:GetComponent("Transform")
|
|
Engine.Log("Init Done")
|
|
end
|
|
|
|
|
|
function OnUpdate(deltaTime)
|
|
local gameObject = Engine.GetGameObjectByTag("Camera")
|
|
transform = gameObject:GetComponent("Transform")
|
|
|
|
local old_rotation = transform:GetRotation()
|
|
|
|
|
|
local rotation = {
|
|
x = old_rotation.x, -- Preserving existing new_rotation on X-axis
|
|
y = new_rotation, -- Updated new_rotation on Y-axis for spinning
|
|
z = old_rotation.z -- Preserving existing new_rotation on Z-axis
|
|
}
|
|
-- Apply the new new_rotation to the Transform component
|
|
transform:SetRotation(rotation)
|
|
new_rotation = new_rotation + (deltaTime * new_rotationSpeed)
|
|
if new_rotation >= 360 then
|
|
new_rotation = 0
|
|
end
|
|
end |