Hello
Im trying to move my camera from one position to another and LookAT other object
Already create a script that set a new position to the camera or another object
but when i try to orbit the camera after i set the new position, the camera return to the original position.
This is my script its very simple.
var MoveCam = pc.createScript('moveCam');
MoveCam.attributes.add('Cam', {type: 'entity'});
MoveCam.attributes.add('Pos', {type: 'vec3', default: [0,0,0] });
MoveCam.attributes.add('Target', {type: 'entity'});
// initialize code called once per entity
MoveCam.prototype.initialize = function() {
this.entity.element.on('mousedown', this.onMouseDown, this);
};
MoveCam.prototype.onMouseDown = function() {
var position = this.Target.getPosition();
this.Cam.setPosition(new pc.Vec3(this.Pos.x, this.Pos.y, this.Pos.z));
this.Cam.lookAt(position);
};
any help it’s very appreciated