User Tools

Site Tools


4rpl:commands:rotateunittowardscell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
4rpl:commands:rotateunittowardscell [2022/12/04 18:19] – [Examples] Removed extra parentheses Vertu4rpl:commands:rotateunittowardscell [2024/07/07 03:01] (current) – Added spacing and advanced example. Warning of X and Z vectors being set to 0. Vertu
Line 6: Line 6:
  
 ===== Description ===== ===== Description =====
-Rotates a unit so that its forward, or positive Z axis, points towards the supplied position, but with rotation confined to the plane of the map (the XZ plane). +Rotates a unit so that its forward, or positive Z axis, points towards the supplied position, but with rotation confined to the plane of the map (the XZ plane).\\ 
-The X, Z coordinates are a position in the plane of the map. +The X, Z coordinates are a position in the plane of the map.\\ 
-The max rotation can be limited by supplying a maxRotationDeg in degrees. +The max rotation can be limited by supplying a maxRotationDeg in degrees.\\ 
-If a negative value is specified for the maxRotationDeg, the rotation will move away from rather than towards the specified target location+If a negative value is specified for the maxRotationDeg, the rotation will move away from rather than towards the specified target location
 + 
 +:WARNING: This API will attempt to set the X and Z rotation vectors to 0 at all times. See [[4rpl:commands:rotateobjtowardscell|RotateObjTowardsCell]] for an API that only modifies the Y vector.\\ 
 +If using objects is undesirable, you can opt to use [[4rpl:commands:rotateunit|RotateUnit]] and handle the rotation process yourself.\\ 
 +Or for a simpler solution: ensure that the rotation from this API is weaker than other uses of RotateUnit.
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
 RotateUnitTowardsCell(<-UID 42 23 1) RotateUnitTowardsCell(<-UID 42 23 1)
 +</code>
 +<code 4rpl>
 +GetUnitRotation(self) ->curRot
 +RotateUnit(self V3(-25 <-curRot.y <-curRot.z) <-TURN_SPEED 0.1 +) #--Ensure this is stronger than TowardsCell
 +RotateUnitTowardsCell(self <-destination.x <-destination.z <-TURN_SPEED)
 </code> </code>
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/rotateunittowardscell.txt · Last modified: 2024/07/07 03:01 by Vertu