What's the best way to make a "ball cam" such as the one in Rocket League?

I have written this code to find the ball entity but I can’t figure out how to get its position. I plan to use the lookAt function with this information.

var CameraFollow = pc.createScript('cameraFollow');
CameraFollow.attributes.add('VolleyBallEntity', {type : 'entity'});
const position = //?;
CameraFollow.prototype.update = function(dt) {
    this.entity.lookAt(position);
};

Hi @Soapy_RL and welcome!

var CameraFollow = pc.createScript('cameraFollow');
CameraFollow.attributes.add('VolleyBallEntity', {type : 'entity'});
const position;
CameraFollow.prototype.update = function(dt) {
    position = this.VolleyBallEntity.getPosition();
    this.entity.lookAt(position);
};

Thank you so much!

1 Like