Thats right, I dont know how to lerp. If someone could tell me how to lerp from the three not values to the three yes values that would be great. If I need to change the values to two attribute entities to use their positions thats fine I can do that.
var Aimer = pc.createScript('aimer');
// PLAYER CAMERA
Aimer.attributes.add('playcam', {
type: 'entity',
});
// FOV WHILE AIMING
Aimer.attributes.add('aimfov', {
type: 'number',
});
// SCOPE
Aimer.attributes.add('scope', {
type: 'entity',
});
// MULTIPLIED WITH GLOBALSENS TO GET REAL SENSITIVITY WHILE AIMING
Aimer.attributes.add('aimsens', {
type: 'number',
});
// POSITION NOT AIMING
Aimer.attributes.add('notx', {
type: 'number',
});
Aimer.attributes.add('noty', {
type: 'number',
});
Aimer.attributes.add('notz', {
type: 'number',
});
// POSITION AIMING
Aimer.attributes.add('yesx', {
type: 'number',
});
Aimer.attributes.add('yesy', {
type: 'number',
});
Aimer.attributes.add('yesz', {
type: 'number',
});
Aimer.attributes.add('useaimlocator', {
type: 'boolean',
});
Aimer.prototype.update = function(dt) {
// THREE DEBUG FUNCTIONS CAN BE REMOVED
Regfovvar = 60;
Aimfovvar = this.aimfov;
Aimsensvar = (Globalsens * this.aimsens)
// MOVES THIS ENTITY AND CHANGES FOV
if(this.app.mouse.isPressed(pc.MOUSEBUTTON_RIGHT))
{
this.entity.setLocalPosition(this.yesx, this.yesy, this.yesz);
this.playcam.camera.fov = this.aimfov;
this.scope.enabled = true;
Realsens = (Globalsens * this.aimsens)
// IF THE BOOLEAN WAS SELECTED THIS ENABLES AND DISABLES THE SCOPE
if(this.useaimlocator === true)
{
this.entity.setPosition(Aimlocx, Aimlocy, Aimlocz)
}
}
// SETS ALL ENTITIES TO DEFAULT VALUES IF NOT AIMING
else
{
this.entity.setLocalPosition(this.notx, this.noty, this.notz);
this.playcam.camera.fov = 60;
this.scope.enabled = false;
Realsens = Globalsens
}
};