SetObjectRotation: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 28: | Line 28: | ||
rotY = 0 | rotY = 0 | ||
rotZ = 0 -- predefined varibles, needed for the math code below | rotZ = 0 -- predefined varibles, needed for the math code below | ||
pirateship = getElementByID ( "pirateship" ) -- assign element named 'pirateship' in map file to | pirateship = getElementByID ( "pirateship" ) -- assign element named 'pirateship' in map file to variable | ||
end | end | ||
function chatboxShipRotateLeft ( playerSource, commandName ) -- On console command 'increaserotations' | function chatboxShipRotateLeft ( playerSource, commandName ) -- On console command 'increaserotations' | ||
Line 39: | Line 38: | ||
setObjectRotation ( pirateship, rotX, rotY, rotZ ) -- Changed rotation is applied | setObjectRotation ( pirateship, rotX, rotY, rotZ ) -- Changed rotation is applied | ||
end | end | ||
function chatboxShipRotateRight ( playerSource, commandName ) -- On console command 'decreaserotations' | function chatboxShipRotateRight ( playerSource, commandName ) -- On console command 'decreaserotations' |
Revision as of 05:05, 5 August 2007
Allows you to change an objects rotation while playing a map. The object can be from the map file or created in a script.
Syntax
bool setObjectRotation ( element object, float rotX, float rotY, float rotZ )
Required Arguments
- Object: The object to be rotated
- rotX: Rotation X value
- rotY: Rotation Y value
- rotZ: Rotation Z value
Returns
Returns true if successful, false otherwise.
Example
In this example, I refer to an object in the map file with the ID "pirateship":
<object id="pirateshi[" posX="-1627.319092" posY="128.543411" posZ="6.581001" rotX="-0.760854" rotY="2.421000" rotZ="0.851000" model="8493"/>
function onResourceStart ( name, root ) rotX = 0 rotY = 0 rotZ = 0 -- predefined varibles, needed for the math code below pirateship = getElementByID ( "pirateship" ) -- assign element named 'pirateship' in map file to variable end function chatboxShipRotateLeft ( playerSource, commandName ) -- On console command 'increaserotations' outputChatBox ( "Rotational values increased" ) rotX = rotX + 10 rotY = rotY + 10 rotZ = rotZ + 10 -- rotations = rotations + 10 setObjectRotation ( pirateship, rotX, rotY, rotZ ) -- Changed rotation is applied end function chatboxShipRotateRight ( playerSource, commandName ) -- On console command 'decreaserotations' outputChatBox ( "Rotational values decreased" ) rotX = rotX - 10 rotY = rotY - 10 rotZ = rotZ - 10 -- rotations = rotations - 10 setObjectRotation ( pirateship, rotX, rotY, rotZ ) -- Changed rotation is applied end addEventHandler ( "onResourceStart", getRootElement(), onResourceStart ) addCommandHandler ( "increaserotations", chatboxShipRotateLeft ) addCommandHandler ( "decreaserotations", chatboxShipRotateRight )
See Also