characterController rotate around an object help!

Is there a way to rotate an Object around a targetObject using the characterController.move(Vector3) function rather than the transform.rotation/transform.rotate function?

You can make the character follow a perfect circle around the target, but if there’s some obstacle the character may get stuck. A better approach is trying to move in a circle, but allowing eventual trajectory changes due to obstacles - this can modify the circle radius sometimes.

The idea is to calculate a curPos vector from the target to the character, then save in newPos this vector rotated by an angle proportional to Time.deltaTime: newPos - curPos is the distance the character must move in this frame. If some object is hit, the character may move closer to or farther from the target, and this new distance will be kept until another obstacle is hit.

I included gravity effects in the script below; just comment this line out if you don’t want gravity.

public Transform target;
public float speed = 30f; // speed in degrees per second
public float gravity = 10f; // gravity, if you want to use it

CharacterController character;

// call this function in LateUpdate
void RotateChar(){
  // make sure the variable "character" contains the controller:
  if (!character) character = GetComponent(CharacterController);
  // curPos = vector from target to character:
  Vector3 curPos = transform.position - target.position;
  // rotate curPos by the appropriate angle and save in newPos:
  Vector3 newPos = Quaternion.Euler(0, speed * Time.deltaTime, 0) * curPos;
  // calculate the displacement to move
  Vector3 displacement = newPos - curPos;
  // if you don't need gravity, comment out this line:
  displacement -= gravity * Vector3.up * Time.deltaTime * Time.deltaTime;
  character.Move(displacement); // move by the distance calculated
  transform.LookAt(target); // keep looking to the target