Talk:SetAngle - ObjectReference

From the CreationKit Wiki
Revision as of 13:40, 6 January 2018 by imported>Rasikko (Make north marker face north.)
Jump to navigation Jump to search

Dropped Object

Bug with dropped objects
--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. 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

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.

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)
	
Float fAngleZ 

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 cell [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)