User Tools

Site Tools


4rpl:commands:rotateunittowardscell

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 RotateObjTowardsCell for an API that only modifies the Y vector.
If using objects is undesirable, you can opt to use 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)

Index

4rpl/commands/rotateunittowardscell.txt · Last modified: 2024/07/07 03:01 by Vertu