~~NOTOC~~ <=[[4rpl:start| Index]] ====== RotateUnitTowardsCell ====== RotateUnitTowardsCell(<-UID <-posX <-posZ <-maxRotationDeg) ===== 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).\\ 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.\\ 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 ===== RotateUnitTowardsCell(<-UID 42 23 1) 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) <=[[4rpl:start| Index]]