Dota 2 Workshop Tools/Scripting/API/Global.RotatePosition

From Valve Developer Community
Jump to: navigation, search


Function Description

Vector RotatePosition(Vector origin, QAngle rotation, Vector inputVector)

Rotates a Vector around an origin point.


Example
-- Converts a vector local to an entity into a world space vector.
--
-- Example: Get a vector 32 units in front of a player.
-- GlobalVectorFromLocal(Vector(32, 0, 0), myPlayerEntity)
--
function GlobalVectorFromLocal(localVec, entity)
 
	-- Here RotatePosition() converts the local space vector into a world space offset from the entity
	-- by rotating it by the entity orentation.
	local offset = RotatePosition(Vector(0, 0, 0), entity:GetAngles(), localVec)
 
	return entity:GetOrigin() + offset
 
end


Parameters

Type Name Description
Vector origin The rotation origin
QAngle rotation The angles to rotate by
Vector inputVector The vector to rotate

Returns

Vector - The rotated vector