Page 1 of 1

Lua: GetUnitRotation (to go along with SetUnitRotation)

Posted: 07 Dec 2011, 07:05
by knorke
I would be nice to have a
x,y,z = GetUnitRotation (unitID)
There is
GetUnitDirection (unitID)
but it is not "compatible" with SetUnitRotation.
As can be seen when doing something like

Code: Select all

local rx,ry,rz=Spring.GetUnitDirection (unitID)
Spring.SetUnitRotation (unitID, rx, ry, rz)
With such function it would be easier to write things like

Code: Select all

while (true) do
 local rx,ry,rz=Spring.GetUnitRotation (unitID)
 rz=rz+0.1 --rotate unit around z-axis
 Spring.SetUnitRotation (unitID, rx, ry, rz)
end
Add the moment you would have to convert from directions to rotations.