Difference between revisions of "Talk:GetAngleZ - ObjectReference"
imported>Sein schatten (Created page with "== Place objects in the direction you are looking == <source lang="papyrus"> float GameX = PlayerRef.GetAngleX() float GameZ = PlayerRef.GetAngleZ() float AngleX = 90 + GameX...") |
(No difference)
|
Revision as of 01:22, 8 December 2020
Place objects in the direction you are looking
<source lang="papyrus"> float GameX = PlayerRef.GetAngleX() float GameZ = PlayerRef.GetAngleZ() float AngleX = 90 + GameX ;needed because without it, X rotation reads -90 to 90. We need it to read 0 to 180. if GameZ < 90 ;needed to convert Skyrim's Z rotation to a notation we can use in trigonometric functions and calculus.
AngleZ = 90 - GameZ
else
AngleZ = 450 - GameZ
endIf ObjectYouWant.MoveTo(PlayerRef, DistanceVar * Math.Sin(AngleX) * Math.Cos(AngleZ), DistanceVar * Math.Sin(AngleX) * Math.Sin(AngleZ), DistanceVar * Math.Cos(AngleX)) ;We might want to add a float equal to the actor's height - 35 to raise the object to roughly chest level. If you will do this, add it to the Z offset parameter. <source>
Source: https://www.reddit.com/r/skyrimmods/comments/k8nvb3/some_calculus_that_can_help_modders_with_moveto/