I’ve been having trouble with rotation not doing what I expect, so I made a simple test device to experiment with it and understand the properties of this implementation better.
I’m stuck at the first hurdle though, because GetYawPitchRollDegrees is silently failing and I don’t know how to find out why.
Here’s my code & set-up:
- I dragged a Log03 from the Content Browser to the game area, ensured it has zeroed rotation
- I created a Verse script rotation_test, compiled it, then dragged the device to the game area too, set to run on start, hidden
- I linked the Script to the Prop as an @editable creative_prop
rotation_test := class(creative_device):
@editable Prop : creative_prop = creative_prop {}
var StartPos : vector3 = vector3{}
var DefaultRot : rotation = rotation {}
var DefaultYPR : [] float = array {}
OnBegin<override>()<suspends>:void=
Print("Start rotation_test")
T := Prop.GetTransform()
set StartPos = T.Translation
Print("start position {StartPos.X},{StartPos.Y},{StartPos.Z}")
set DefaultRot = T.Rotation
Print("start rotation {ToString(DefaultRot)}")
spawn{ Update() }
Update()<suspends>:void=
loop:
Sleep(3.0)
T := Prop.GetTransform()
if (DefaultYPR = DefaultRot.GetYawPitchRollDegrees()):
Print("got default rotation YPR")
else:
Print("could not get default rotation YPR")
if (Yaw := DefaultYPR[0], Pitch := DefaultYPR[1], Roll := DefaultYPR[2]):
Print("Default rot {Yaw},{Pitch},{Roll}")
else:
Print("could not get default YPR")
The output log contains:
[2023.05.01-21.46.18:805][184]LogVerse: : Start rotation_test
[2023.05.01-21.46.18:805][184]LogVerse: : start position -3112.000000,4604.000000,11514.759663
[2023.05.01-21.46.18:806][184]LogVerse: : start rotation Axis: {x=1.000000,y=0.000000,z=0.000000} Angle: 0.000000
[2023.05.01-21.46.21:822][546]LogVerse: : could not get default rotation YPR
[2023.05.01-21.46.21:822][546]LogVerse: : could not get default YPR
[2023.05.01-21.46.24:822][906]LogVerse: : could not get default rotation YPR
[2023.05.01-21.46.24:822][906]LogVerse: : could not get default YPR
How can I track down the problem?