Moving a player entity in a circle

Hey guys,

How could I script a player entities controller to only move in around a circle?

My code for doing this previously on unity was as follows:

var pivotPoint =;
var radii : float;
var walkSpeed = 0.5;
var jumpSpeed = 15.0;
var angle = 0.0;
private var posNow : Vector3;
private var posStart : Vector3;
function Awake() {
    posNow = transform.position;
    posStart = posNow;
    radii = posStart.magnitude; // set the radii from the starting position
function FixedUpdate() {
    posNow = transform.position;
    var controller : CharacterController = GetComponent(CharacterController);
    angle = Vector3.Angle(posStart, posNow);
    transform.rotation = Quaternion.AngleAxis(-angle, Vector3.up);
    var walkMovement = Input.GetAxis("Horizontal") * walkSpeed;
    var rAngle = angle * Mathf.Deg2Rad;
    var movX = radii * Mathf.Cos(rAngle);
    var movZ = radii * Mathf.Sin(rAngle);
    var movement = Vector3(movX, posNow.y, movZ) * walkMovement + Physics.gravity;
    controller.Move(movement * Time.deltaTime);
@script RequireComponent(CharacterController)

How would I implement this in PlayCanvas?


Can you break the problem down a bit? Are you asking:

  • How to move an entity in a circle?
  • How to write a physical character controller?
  • Something else?

What have you tried? What are you struggling with specifically?