Difference between revisions of "Talk:SetAngle - ObjectReference"
imported>Fg109 (dropped objects bug) |
imported>Rasikko m (→Force an interior compass to point north.: Removed unnecessary variable.) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
[[Talk:SetPosition_-_ObjectReference#Dropped_Objects|Bug with dropped objects]]<br> | [[Talk:SetPosition_-_ObjectReference#Dropped_Objects|Bug with dropped objects]]<br> | ||
--[[User:Fg109|Fg109]] 11:25, 2 May 2012 (EDT) | --[[User:Fg109|Fg109]] 11:25, 2 May 2012 (EDT) | ||
== Conventions for these angles == | |||
Assuming that this function applies the same kinds of angles that the Creation Kit uses (and why wouldn't it?), it uses ''clockwise (left-handed) extrinsic Euler rotations with a ZYX sequence''. [[User:DavidJCobb|DavidJCobb]] ([[User talk:DavidJCobb|talk]]) 2014-08-08T23:24:20 (EDT) | |||
Yeah it's been known for some time that the engine uses a ZYX ordering. --[[User:Terra Nova2|Terra Nova2]] ([[User talk:Terra Nova2|talk]]) 2014-08-11T11:43:34 (EDT) | |||
== Player.SetAngle() workaround == | |||
The Player object can only be rotated by the Z axis unless collisions have been disabled. | |||
Here's some sample code from screenshot.psc to let you modify the X and Y angle: | |||
<code> | |||
; Rotate the camera | |||
; Hack! The X angle doesn't get set if collisions are off, so | |||
; turn collisions ON for a very brief period | |||
ToggleCollisions() | |||
; Set the angle on the player, this will move the camera | |||
GetPlayer().SetAngle(afAngleX, afAngleY, afAngleZ) | |||
; And reset collisions off again, we don't want the player to start falling | |||
ToggleCollisions() | |||
</code> | |||
--[[User:Obstipator|Obstipator]] ([[User talk:Obstipator|talk]]) 2014-11-09T13:56:27 (EST) | |||
== Force an interior compass to point north. == | |||
This was a little experiment I tried out. Just turn the north marker so that it faces north. Since the compass is based on the north marker.. if you enter a cell with a north marker pointing east, the compass will think you are entering from the east. | |||
<source lang="papyrus"> | |||
Function SetNorthMarkerToPointNorth() Global | |||
; Sets the North Marker in a cell to point north. | |||
Actor Player = Game.GetPlayer() | |||
Form kMarker = Game.GetFormFromFile(0x00000003, "Skyrim.ESM") ; NorthMarkers | |||
ObjectReference kNorthMarker = Game.FindClosestReferenceOfTypeFromRef(kMarker, Player, 120000.0) | |||
if Player.IsInInterior() | |||
if kNorthMarker | |||
; check if it's facing north | |||
if kNorthMarker.GetAngleZ() > 0.0 | |||
; Turn the thing north. | |||
kNorthMarker.SetAngle(0.0, 0.0, 0.0) | |||
endif | |||
else | |||
return none | |||
endif | |||
else | |||
return none | |||
endif | |||
EndFunction | |||
</source> | |||
Only thing is, the compass wont reset until you exit and re-enter the cell. If one were to seriously use this though, they'll need to store the marker and the marker's original z rotation prior to the change so that you can revert the changes for whatever reason. I'm thinking if it were possible to call [[GetParentCell - ObjectReference]] on objects in exterior cells, it would be possible to match the inside compass to that of the inside one. --[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-01-06T13:40:48 (EST) |
Latest revision as of 13:44, 6 January 2018
Dropped Object[edit source]
Bug with dropped objects
--Fg109 11:25, 2 May 2012 (EDT)
Conventions for these angles[edit source]
Assuming that this function applies the same kinds of angles that the Creation Kit uses (and why wouldn't it?), it uses clockwise (left-handed) extrinsic Euler rotations with a ZYX sequence. DavidJCobb (talk) 2014-08-08T23:24:20 (EDT)
Yeah it's been known for some time that the engine uses a ZYX ordering. --Terra Nova2 (talk) 2014-08-11T11:43:34 (EDT)
Player.SetAngle() workaround[edit source]
The Player object can only be rotated by the Z axis unless collisions have been disabled.
Here's some sample code from screenshot.psc to let you modify the X and Y angle:
; Rotate the camera
; Hack! The X angle doesn't get set if collisions are off, so
; turn collisions ON for a very brief period
ToggleCollisions()
; Set the angle on the player, this will move the camera
GetPlayer().SetAngle(afAngleX, afAngleY, afAngleZ)
; And reset collisions off again, we don't want the player to start falling
ToggleCollisions()
--Obstipator (talk) 2014-11-09T13:56:27 (EST)
Force an interior compass to point north.[edit source]
This was a little experiment I tried out. Just turn the north marker so that it faces north. Since the compass is based on the north marker.. if you enter a cell with a north marker pointing east, the compass will think you are entering from the east.
Function SetNorthMarkerToPointNorth() Global
; Sets the North Marker in a cell to point north.
Actor Player = Game.GetPlayer()
Form kMarker = Game.GetFormFromFile(0x00000003, "Skyrim.ESM") ; NorthMarkers
ObjectReference kNorthMarker = Game.FindClosestReferenceOfTypeFromRef(kMarker, Player, 120000.0)
if Player.IsInInterior()
if kNorthMarker
; check if it's facing north
if kNorthMarker.GetAngleZ() > 0.0
; Turn the thing north.
kNorthMarker.SetAngle(0.0, 0.0, 0.0)
endif
else
return none
endif
else
return none
endif
EndFunction
Only thing is, the compass wont reset until you exit and re-enter the cell. If one were to seriously use this though, they'll need to store the marker and the marker's original z rotation prior to the change so that you can revert the changes for whatever reason. I'm thinking if it were possible to call GetParentCell - ObjectReference on objects in exterior cells, it would be possible to match the inside compass to that of the inside one. --Rasikko (talk) 2018-01-06T13:40:48 (EST)