How do I stop the camera from rotating?

How do I stop the camera from rotating with the ball
visual demonstration

You need to provide more context to the problem you are facing. For example, include a link to a project and describe the steps to reproduce the problem. Otherwise, forum members will not be able to assist you.

step 1: click the link
step 2: move

Try this script:

var Follow = pc.createScript('follow');

Follow.attributes.add('target', {
    type: 'entity',
    title: 'Target',
    description: 'The Entity to follow'

Follow.attributes.add('distance', {
    type: 'number',
    default: 4,
    title: 'Distance',
    description: 'How far from the Entity should the follower be'

// initialize code called once per entity
Follow.prototype.initialize = function() {
    this.currentPos =;
    this.currentPos.z += this.distance;

    this.targetPos = new pc.Vec3();

// update code called every frame
Follow.prototype.update = function(dt) {
    if (! return;

    // get the position of the target entity
    this.targetPos.z += this.distance;

    // smoothly interpolate towards the target position
    this.currentPos.lerp(this.currentPos, this.targetPos, 0.1);

    // set the position for this entity

And set distance to 3, say.

And most important!!! Make the entity ‘Camera’ a sibling of ‘Player’, NOT a child.


I’m assuming the camera is attached to the player, or in this case, the ball as a child. If this is the case, it is natural for the rotation to be set accordingly with the ball’s. If you want the camera to move when the ball moves, you have to use code to set it’s position to the ball, and you can also add an offset to adjust it to your liking. This way, the ball won’t have the rotating issue.

how do i make it a sibling



1 Like