unit scripting -> relative rotation and movement
Posted: 08 May 2011, 17:26
For lua unit scripting, should piece movement/rotation be relative to their local rotation rather than the 'world' axes? Or is there a separate way to script units to rotate or move relative to a normal determined within the script?
So you can see what I mean I've created a small experiment with a bit of script below, modifying a turret script (the armllt) so that it rotates along the y axis and the x axis then moves its barrel. I'd expect the barrel to move straight relative to it's new found rotation rather than along the z axis.
function script.Create()
c = 0
while ( c < 200) do --for testing
Turn(turret, y_axis, math.rad(-45), 0.5)
Turn(barrel, x_axis, -math.rad(-30), 0.25)
WaitForTurn(turret, y_axis)
WaitForTurn(barrel, x_axis)
Turn(turret, y_axis, math.rad(45), 0.5)
Turn(barrel, x_axis, -math.rad(30), 0.25)
WaitForTurn(turret, y_axis)
WaitForTurn(barrel, x_axis)
Sleep(100)
Move(barrel,z_axis, -5, 100)
WaitForMove(barrel, z_axis)
Move(barrel,z_axis, 5, 60)
WaitForMove(barrel, z_axis)
Sleep(500)
c = c +1
end
end
So you can see what I mean I've created a small experiment with a bit of script below, modifying a turret script (the armllt) so that it rotates along the y axis and the x axis then moves its barrel. I'd expect the barrel to move straight relative to it's new found rotation rather than along the z axis.
function script.Create()
c = 0
while ( c < 200) do --for testing
Turn(turret, y_axis, math.rad(-45), 0.5)
Turn(barrel, x_axis, -math.rad(-30), 0.25)
WaitForTurn(turret, y_axis)
WaitForTurn(barrel, x_axis)
Turn(turret, y_axis, math.rad(45), 0.5)
Turn(barrel, x_axis, -math.rad(30), 0.25)
WaitForTurn(turret, y_axis)
WaitForTurn(barrel, x_axis)
Sleep(100)
Move(barrel,z_axis, -5, 100)
WaitForMove(barrel, z_axis)
Move(barrel,z_axis, 5, 60)
WaitForMove(barrel, z_axis)
Sleep(500)
c = c +1
end
end