So last Friday my project was running perfectly no errors and I could drop and pickup weapons in my game but now cloning just doesn’t work!
I’ve tried many work arounds but it always equals null…
Help😅?
These are the scripts I’m using…
pickup script
var PickUp = pc.createScript('pickUp');
PickUp.attributes.add('weapon_name', {
title: 'Weapon name',
type: 'string',
});
PickUp.attributes.add('type', {
title: 'Weapon type?',
type: 'string',
});
PickUp.attributes.add('indexnum', {
title: 'Weapon index #',
type: 'number',
});
PickUp.attributes.add('player', {
title: 'Player',
type: 'entity',
});
PickUp.attributes.add('text', {
title: 'holder',
type: 'entity',
});
PickUp.attributes.add('origin', {
title: 'originentity',
type: 'entity',
});
PickUp.attributes.add('range', {
title: 'Pickuprange',
type: 'entity',
});
// initialize code called once per entity
PickUp.prototype.initialize = function() {
this.playerintrange = false;
this.range.collision.on('triggerenter', this.onTriggerEnter, this);
this.range.collision.on('triggerleave', this.onTriggerLeave, this);
};
// update code called every frame
PickUp.prototype.update = function(dt) {
if(this.playerintrange == true /*&& this.text.element.text == 'E to pickup ' + this.weapon_name */){
if(this.app.keyboard.isPressed(pc.KEY_E))
{
this.taken();
}
}
};
PickUp.prototype.onTriggerEnter = function(result){
if(result){
if(result.tags.has('player'))
{
this.playerintrange = true;
this.text.enabled = true;
this.text.element.text = 'E to pickup ' + this.weapon_name;
}
}
};
PickUp.prototype.onTriggerLeave = function(result) {
if(result){
if(result.tags.has('player'))
{
this.playerintrange = false;
this.text.enabled = false;
}
}
};
/*
var obj = this.app.root.findByName(this.phystype).clone();
this.app.root.addChild(obj);
obj.reparent(this.app.root);
obj.setPosition(this.app.root.findByName(this.ammotype).getPosition());
obj.setRotation(this.app.root.findByName(this.ammotype).getRotation());
obj.enabled = true;
setTimeout(() => {
obj.destroy();
}, 2000);
}*/
PickUp.prototype.taken = function() {
this.app.fire('PickUp:player', this.weapon_name,this.indexnum,this.type);
setTimeout(() => {
this.entity.destroy();
}, 100);
};
FirstPersonMovementV2
var FirstPersonMovementV2 = pc.createScript('firstPersonMovementV2');
FirstPersonMovementV2.attributes.add('originEntity', {
type: 'entity',
description: 'Origin of the arms'
});
/*FirstPersonMovementV2.attributes.add('rayend', {
type: 'entity',
description: 'ray'
});*/
FirstPersonMovementV2.attributes.add('Wepman', {
type: 'entity',
description: 'Gun manager'
});
FirstPersonMovementV2.attributes.add('crosshair', {
type: 'entity',
description: 'crosshair to guide player where to shoot'
});
FirstPersonMovementV2.attributes.add('camera', {
type: 'entity',
description: 'Optional, assign a camera entity, otherwise one is created'
});
FirstPersonMovementV2.attributes.add('power', {
type: 'number',
default: 2500,
description: 'Adjusts the speed of player movement'
});
FirstPersonMovementV2.attributes.add('powerCrouching', {
type: 'number',
default: 2000,
description: 'Adjusts the speed of player movement when crouching'
});
FirstPersonMovementV2.attributes.add('lookSpeed', {
type: 'number',
default: 0.25,
description: 'Adjusts the sensitivity of looking'
});
FirstPersonMovementV2.attributes.add('cameraHeight', {
type: 'number',
default: 0.5,
description: 'Adjusts the Y position of the camera'
});
FirstPersonMovementV2.attributes.add('cameraSmoothingUp', {
type: 'number',
default: 0.25,
description: 'Camera smooth amount for crouching'
});
FirstPersonMovementV2.attributes.add('cameraSmoothingDown', {
type: 'number',
default: 0.15,
description: 'Camera smooth amount for crouching'
});
FirstPersonMovementV2.attributes.add('playerHeight', {
type: 'number',
default: 2.0,
description: 'Adjusts the Y position of the camera'
});
FirstPersonMovementV2.attributes.add('debug', {
type: 'boolean',
default: false,
description: 'Debug player movement'
});
FirstPersonMovementV2.attributes.add('thirdpersonenabler', {
type: 'boolean',
description: 'Dev thing'
});
FirstPersonMovementV2.attributes.add('firerate', {type: 'number',default : 25});
// initialize code called once per entity
FirstPersonMovementV2.prototype.initialize = function() {
this.currentweapon = this.entity.findByName('AR-15');
// player child entities
this.playerCollisionUpper = this.entity.findByName('player-collision-upper');
this.playerCollisionLower = this.entity.findByName('player-collision-lower');
this.playerModel = this.entity.findByName('player-model');
//this.head.enabled = false;
// physics
this.force = new pc.Vec3();
this.eulers = new pc.Vec3();
this.velocity = new pc.Vec3();
this.crouchRaycastStart = new pc.Vec3();
this.crouchRaycastEnd = new pc.Vec3();
this.crouchRaycastLastAngle = 0;
this.playerHeightCrouching = this.playerCollisionLower.collision.height;
this.lastShootTime = 0;
this.lastAimTime = 0;
this.lastReloadTime = 0;
this.isSprinting = false;
this.isShooting = false;
this.thirdpersontoggler = false;
// player data
this.playerSpawnPosition = this.entity.getPosition().clone();
this.playerHeightCurrent = this.playerHeight;
// states
this.playerMoving = false;
this.playerCrouching = false;
this.playerJumping = false;
// (optional) enable ccd, prevents rigidbody clipping through at high speeds
const body = this.entity.rigidbody.body;
body.setCcdMotionThreshold(1);
body.setCcdSweptSphereRadius(0.1);
body.setContactProcessingThreshold(0.1);
// camera
this.cameraHeightCurrent = this.playerHeight * this.cameraHeight;
// reparent camera if not a child of this entity
if (this.entity.children.indexOf(this.camera) < 0) {
this.camera.reparent( this.entity );
}
// debug
this.debugThirdPerson = false; // toggle with 'X' key
this.debugCamLocalPosition = new pc.Vec3();
//if(this.currentweapon = null){this.currentweapon = this.gun1.name;}
// events
var app = this.app;
app.on(
'PickUp:' + this.entity.name, function(weapon,index,type){
if(type == 'Primary'){this.originEntity.script.weaponHandler.inventorycheck1(index);this.Wepman.script.weaponScroll.pickup(type)}
if(type == 'Secondary'){this.originEntity.script.weaponHandler.inventorycheck2(index);this.Wepman.script.weaponScroll.pickup(type)}
// this.setweapon(this.entity.findByName(weapon))
},this);
// Listen for mouse move events
app.mouse.on("mousemove", this._onMouseMove, this);
// when the mouse is clicked hide the cursor
app.mouse.on('mousedown', function(event) {
app.mouse.enablePointerLock();
if(event.button === pc.MOUSEBUTTON_LEFT){
this.isShooting = true;
}
if(event.button === pc.MOUSEBUTTON_RIGHT){
this.isaiming = true;
this.crosshair.enabled = false;
}
}, this);
//Up
this.app.mouse.on('mouseup', function(event) {
if(event.button === pc.MOUSEBUTTON_LEFT){
this.isShooting = false;
}
if(event.button === pc.MOUSEBUTTON_RIGHT){
app.fire('Motion:Arms', 'Hip');
this.isaiming = false;
this.crosshair.enabled = true;
}
}, this);
// Check for required components
if (!this.entity.collision) {
console.error("First Person Movement script needs to have a 'collision' component");
}
if (!this.entity.rigidbody || this.entity.rigidbody.type !== pc.BODYTYPE_DYNAMIC) {
console.error("First Person Movement script needs to have a DYNAMIC 'rigidbody' component");
}
};
// update code called every frame
FirstPersonMovementV2.prototype.update = function(dt) {
// If a camera isn't assigned from the Editor, create one
if (!this.camera) {
this._createCamera();
}
var force = this.force;
var app = this.app;
var forward = this.camera.forward;
var right = this.camera.right;
var x = 0;
var z = 0;
//let ammo = 20;
var W = app.keyboard.isPressed(pc.KEY_W);
var A = app.keyboard.isPressed(pc.KEY_A);
var S = app.keyboard.isPressed(pc.KEY_S);
var D = app.keyboard.isPressed(pc.KEY_D);
var Shift = app.keyboard.isPressed(pc.KEY_SHIFT);
var C = app.keyboard.isPressed(pc.KEY_C);
if(Shift && this.isaiming == false) {this.isSprinting = true; }else {this.isSprinting = false;}
//if(this.weaponinrange = true && app.keyboard.wasPressed(pc.KEY_E)){this.getWorldPoint();}
if(app.keyboard.wasPressed(pc.KEY_F))
{
if(this.currentweapon.tags.has('Primary')){
this.originEntity.script.weaponHandler.inventorydrop1('drop',this.currentweapon);}
if(this.currentweapon.tags.has('Secondary')){
this.originEntity.script.weaponHandler.inventorydrop2('drop',this.currentweapon);}
}
if(W|A|S|D){
if(this.isSprinting == true){
app.fire('Motion:Origin', 'Sprinting');
app.fire('Motion:Leg_right', 'Walking');
app.fire('Motion:Leg_left', 'Walking');
} else
app.fire('Motion:Origin', 'Walking');
app.fire('Motion:Leg_right', 'Walking');
app.fire('Motion:Leg_left', 'Walking');
}else{
app.fire('Motion:Leg_right', 'Idle');
app.fire('Motion:Leg_left', 'Idle');
}
if(W) {
//if(!this.swinging) //app.fire('Motion:Shoulders', 'Walking');
x += forward.x;
z += forward.z;
}
if(A) {
//if(!this.swinging) //app.fire('Motion:Shoulders', 'Walking');
x -= right.x;
z -= right.z;
}
if(S) {
//if(!this.swinging) //app.fire('Motion:Shoulders', 'Walking');
x -= forward.x;
z -= forward.z;
}
if(D) {
//if(!this.swinging) //app.fire('Motion:Shoulders', 'Walking');
x += right.x;
z += right.z;
}
if(x !== 0 && z !== 0) {
if(Shift) {force.set(x, 0, z).normalize().scale(this.power*2);}else{
force.set(x, 0, z).normalize().scale(this.power);}
this.entity.rigidbody.applyForce(force);
}
// attributes
let playerHeight = this.playerHeight;
// Crouching mechanic: input
if (C) {
this.playerCrouching = true;
}
else if (this.playerCrouching) {
// verify that there is room to stand up
this.playerCrouching = this.raycastCrouch();
}
// Crouching mechanic: apply
if (this.playerCrouching) {
playerHeight = this.playerHeightCrouching;
power = this.powerCrouching;
}
this._updateCrouchMechanic( playerHeight, dt );
// update camera
this._updateCamera();
this.aim(this.currentweapon);
if(this.thirdpersontoggler == true)
{
//this.crosshair.enabled = false;
//this.head.enabled = true;
//this.playerModel.render.enabled = true;
}else
{
//this.crosshair.enabled = true;
//this.head.enabled = false;
//this.playerModel.render.enabled = false;
}
};
FirstPersonMovementV2.prototype.firecheck = function (firerate) {
if(this.currentweapon.tags.has('Empty'))return;
if(firerate == undefined|firerate == null){ firerate = this.firerate}
if(Date.now() - this.lastShootTime > 2500) {}
if(!this.isSprinting && this.isShooting && Date.now() - this.lastShootTime > firerate && Date.now() - this.lastReloadTime > 2500) {
this.app.fire(this.currentweapon.name +':Shoot', -1 ,this.currentweapon.name);
/* recoil */
this.lastShootTime = Date.now();}
};
FirstPersonMovementV2.prototype.setweapon = function(weapon) {
this.currentweapon = weapon;
}
/*
FirstPersonMovementV2.prototype.getWorldPoint = function () {
var from = this.originEntity.getPosition();
var to = this.rayend.getPosition();
var hitPoint = to;
var app = this.app;
var hit = app.systems.rigidbody.raycastFirst(from, to);
if(hit){
if(hit.entity.tags.has('pickUp')){hit.entity.script.pickUp.taken();}
}
};*/
FirstPersonMovementV2.prototype.aim = function(weapon) {
//if(!weapon.tags.has('Empty')){
if(!this.isSprinting && this.isaiming && Date.now() - this.lastAimTime > 25 && Date.now() - this.lastReloadTime > 2500) {
if(weapon.tags.has('AR')){this.app.fire('Motion:Arms', 'Ads');}
if(weapon.tags.has('Pistol')){this.app.fire('Motion:Arms', 'Ads2');}
this.lastAimTime = Date.now();}
//}
}
//
// Utilities
//
FirstPersonMovementV2.prototype._updateCrouchMechanic = function (heightTarget, dt) {
// on height change
let height = this.playerHeightCurrent;
if (height !== heightTarget) {
this.playerHeightCurrent = heightTarget;
// (optional) instantly scale player model
//this.playerModel.setLocalScale(1, heightTarget * 0.5, 1);
// (optional) instantly offset player model. usefull for a crouching skeletal animations.
//this.playerModel.setLocalPosition(0, (this.playerHeight - heightTarget) * 0.5, 0);
// disable the upper collision body when crouching
const upperCollisionEnabled = this.playerCollisionUpper.collision.enabled;
if (this.playerCrouching) {
if (upperCollisionEnabled) {
this.playerCollisionUpper.collision.enabled = false;
this.playerCollisionUpper.enabled = false;
}
}
else {
if (!upperCollisionEnabled) {
this.playerCollisionUpper.collision.enabled = true;
this.playerCollisionUpper.enabled = true;
}
}
}
// smoothing //
// setup smoothing speed based on going up or down
const smoothing = this.playerCrouching ? this.cameraSmoothingDown : this.cameraSmoothingUp;
const t = Math.min(dt / smoothing, 1.0);
/// update camera height smooth
let cameraHeightTarget = heightTarget * this.cameraHeight * 0.5; // - this.playerHeight * 0.5;
this.cameraHeightCurrent = pc.math.lerp(this.cameraHeightCurrent, cameraHeightTarget, t);
/// (optional) update player model smooth, not ideal for skeletal animations.
// scale
let playerModelScaleY = this.playerModel.getLocalScale().y;
playerModelScaleY = pc.math.lerp( playerModelScaleY, heightTarget * 0.5, t);
this.playerModel.setLocalScale(0.4, playerModelScaleY, 0.4);
// pos
let playerModelPosY = this.playerModel.getLocalPosition().y;
const scaleDelta = - playerModelScaleY;
this.playerModel.setLocalPosition(0, -scaleDelta, 0);
};
// Raycast above player when in Crouching State
FirstPersonMovementV2.prototype.raycastCrouch = function() {
const height = this.playerHeightCurrent;
const radius = this.playerCollisionLower.collision.radius;
const positionStart = this.playerCollisionLower.getPosition();
const positionEntity = this.entity.getPosition();
const padding = -0.15; // add a little buffer to radius to cast from inside
const precision = 9; // amount of raycasters to cast
// raycaster is colliding with rigidbody
let colliding = false;
// nifty optimization (starts angle at last hit angle)
let angleOffset = this.crouchRaycastLastAngle;
// make a circle of raycasters to cast above player
for (let i = 0; i < precision; i ++) {
// setup raycaster positions
this.crouchRaycastStart.copy(positionStart);
this.crouchRaycastEnd.copy(positionEntity);
this.crouchRaycastEnd.y += this.playerHeight;
// offset raycaster positions in a circle, index 0 reserved for center raycast
let phi = 0;
if (i !== 0) {
const len = precision - 1;
const slice = ((i - 1) / len);
const pizza = 360 * pc.math.DEG_TO_RAD;
phi = (pizza * slice) + angleOffset;
const x = Math.cos( phi ) * (radius + padding);
const z = Math.sin( phi ) * (radius + padding);
this.crouchRaycastStart.x += x;
this.crouchRaycastStart.z += z;
this.crouchRaycastEnd.x += x;
this.crouchRaycastEnd.z += z;
}
// raycast from center to to player height
const result = this.app.systems.rigidbody.raycastFirst(this.crouchRaycastStart, this.crouchRaycastEnd);
// is raycaster colliding with a rigidbody?
colliding = result && result.entity.rigidbody;
// debug: render line
if (this.debug) {
this.app.renderLine(this.crouchRaycastStart, this.crouchRaycastEnd, colliding ? pc.Color.RED : pc.Color.GREEN);
}
// exit loop when collision success
if (colliding) {
this.crouchRaycastLastAngle = phi;
break;
}
}
return colliding;
};
FirstPersonMovementV2.prototype._createCamera = function () {
// If user hasn't assigned a camera, create a new one
this.camera = new pc.Entity();
this.camera.setName("First Person Camera");
this.camera.addComponent("camera");
this.entity.addChild(this.camera);
this.camera.translateLocal(0, this.cameraHeight, 0);
};
FirstPersonMovementV2.prototype._updateCamera = function () {
// update camera angle from mouse events
this.camera.setLocalEulerAngles(this.eulers.y, this.eulers.x, 0);
this.originEntity.setLocalEulerAngles(this.eulers.y, this.eulers.x, 0);
this.playerModel.setLocalEulerAngles(0, this.eulers.x, 0);
// update position
this.camera.setLocalPosition(0, this.cameraHeightCurrent, 0);
this.originEntity.setLocalPosition(0, this.cameraHeightCurrent, 0);
if(this.thirdpersonenabler == true)
{
this.debugThirdPersonCamera();
}
};
//
// Input
//
FirstPersonMovementV2.prototype._onMouseMove = function(e) {
if(pc.Mouse.isPointerLocked()) {
this.eulers.x -= this.lookSpeed * e.dx;
this.eulers.y -= this.lookSpeed * e.dy;
this.eulers.y = Math.min(this.eulers.y, 85);
this.eulers.y = Math.max(this.eulers.y, -85);
}
};
//
// Debug
//
FirstPersonMovementV2.prototype.debugThirdPersonCamera = function() {
const camForward = this.camera.forward;
const camDistance = 6;
// toggle camera
if (this.app.keyboard.wasPressed(pc.KEY_X)) {
this.debugThirdPerson = !this.debugThirdPerson;
// on toggle state change
if (this.debugThirdPerson) {
// setup cam for TPV
const camLocalPosition = this.camera.getLocalPosition();
this.debugCamLocalPosition.copy( camLocalPosition );
this.thirdpersontoggler = true;
}
else {
// reset cam to FPV
this.camera.setLocalPosition( 0, this.cameraHeightCurrent, 0);
this.thirdpersontoggler = false;
}
}
// update camera position
if (this.debugThirdPerson) {
const cameraHeight = this.cameraHeightCurrent;
this.camera.setLocalPosition(
-camForward.x * camDistance,
-camForward.y * camDistance + cameraHeight,
-camForward.z * camDistance);
}
};
WeaponHanlder
var WeaponHandler = pc.createScript('weaponHandler');
WeaponHandler.attributes.add('Startweapon', {
title: 'Start with Weapon?',
type: 'boolean'
});
WeaponHandler.attributes.add('player', {
title: 'Player',
type: 'entity'
});
WeaponHandler.attributes.add('cam_origin', {
title: 'Camera Origin',
type: 'entity'
});
WeaponHandler.attributes.add('Drop_Spot', {
title: 'Drop Postition',
type: 'entity'
});
WeaponHandler.attributes.add('AmmoDisplay', {
title: 'Display',
type: 'entity'
});
WeaponHandler.attributes.add('throwForce', {
type : 'number',
default : 2,
min: -0.5,
max: 0.5,
step: 1,
});
WeaponHandler.attributes.add('throwTorque', {
type : 'number',
default : 2,
min: -0.5,
max: 0.5,
step: 1,
});
WeaponHandler.attributes.add('Primary', {
title: 'Primary Weapons',
type: 'string',
array : true
//precision: 2,
});
WeaponHandler.attributes.add('Secondary', {
title: 'Secondary Weapons',
type: 'string',
array : true
//precision: 2,
});
WeaponHandler.attributes.add('Pri_index', {
title: 'Primary Index',
type: 'number',
default: 0,
/* min: 0,
max: 30,
step: 1,*/
});
WeaponHandler.attributes.add('Sec_index', {
title: 'Secondary Index',
type: 'number',
default: 0,
/* min: 0,
max: 15,
step: 1,*/
});
// initialize code called once per entity
WeaponHandler.prototype.initialize = function() {
this.sprinting = false;
if(this.Startweapon)
{
this.weapon_1 = this.entity.findByName(this.Primary[this.Pri_index]);
this.weapon_2 = this.entity.findByName(this.Secondary[this.Sec_index]);
this.weapon_1.enabled = true;
this.weapon_2.enabled = true;
}else
{
this.weapon_1 = this.entity.findByName('N/A_pri');
this.weapon_2 = this.entity.findByName('N/A_sec');
this.weapon_1.enabled = true;
this.weapon_2.enabled = true;
}
};
WeaponHandler.prototype.inventorycheck1 = function(primary) {
//if(!this.weapon_1.name == 'N/A_pri'){this.inventorydrop1('swap',this.weapon_1)}else
this.weapon_1.enabled = false;
this.weapon_1 = this.entity.findByName(this.Primary[primary]);
this.weapon_1.enabled = true;
this.AmmoDisplay.enabled = false;
};
WeaponHandler.prototype.inventorycheck2 = function(secondary) {
//if(!this.weapon_2.name == 'N/A_sec'){this.inventorydrop2('swap',this.weapon_2)}else
this.weapon_2.enabled = false;
this.weapon_2 = this.entity.findByName(this.Secondary[secondary]);
this.weapon_2.enabled = true;
this.AmmoDisplay.enabled = false;
};
WeaponHandler.prototype.inventorydrop1 = function(action,weapon) {
if(action == 'drop'){
this.weapon_1.enabled = false;
const pickup2 = this.entity.findByName(this.weapon_1.name + '_pickup').clone();
this.app.root.addChild(pickup2);
pickup2.reparent(this.app.root);
pickup2.setPosition(this.Drop_Spot.getPosition());
pickup2.setRotation(this.Drop_Spot.getRotation());
pickup2.enabled = true;
pickup2.rigidbody.applyImpulse(this.cam_origin.forward.scale(this.throwForce));
pickup2.rigidbody.applyTorque(this.cam_origin.forward.scale(this.throwTorque,0,0));
this.weapon_1 = this.entity.findByName('N/A_pri');
this.weapon_1.enabled = true;
}
};
WeaponHandler.prototype.inventorydrop2 = function(action,weapon) {
if(action == 'drop' ){
this.weapon_2.enabled = false;
const pickup2 = this.entity.findByName(this.weapon_2.name+'_pickup').clone();
this.app.root.addChild(pickup2);
pickup2.reparent(this.app.root);
pickup2.setPosition(this.Drop_Spot.getPosition());
pickup2.setRotation(this.Drop_Spot.getRotation());
pickup2.enabled = true;
pickup2.rigidbody.applyImpulse(this.cam_origin.forward.scale(this.throwForce));
pickup2.rigidbody.applyTorque(this.cam_origin.forward.scale(this.throwTorque,0,0));
this.weapon_2 = this.entity.findByName('N/A_sec');
this.weapon_2.enabled = true;
}
};
// update code called every frame
WeaponHandler.prototype.update = function(dt) {
var app = this.app;
var Shiftp = app.keyboard.wasPressed(pc.KEY_SHIFT);
var Shiftr = app.keyboard.wasReleased(pc.KEY_SHIFT);
var R = app.keyboard.isPressed(pc.KEY_R)
/*animation*/
/*primary weapon specific animations*/
if(this.weapon_1.enabled == true )
{
if(this.weapon_1.tags.has('Empty'))
{
app.fire('Motion:arm_left', 'Empty');
app.fire('Motion:arm_right', 'Empty');
this.AmmoDisplay.element.text = 'Primary slot: N /A';
}else
if(this.weapon_1.tags.has('AR') ||this.weapon_1.tags.has('SMG')||this.weapon_1.tags.has('LMG'))
{
this.player.script.firstPersonMovementV2.setweapon(this.weapon_1);
app.fire('Motion:arm_left', 'Primary');
app.fire('Motion:arm_right', 'Primary');
}
}
/*animation*/
/*Secondary weapon specific animations*/
if(this.weapon_2.enabled == true )
{
if(this.weapon_2.tags.has('Empty'))
{
app.fire('Motion:arm_left', 'Empty');
app.fire('Motion:arm_right', 'Empty');
this.AmmoDisplay.element.text = 'Secondary slot: N /A';
}else
if(this.weapon_2.tags.has('Pistol')){
this.player.script.firstPersonMovementV2.setweapon(this.weapon_2);
if(this.weapon_2.tags.has('Stockless'))
{
app.fire('Motion:arm_left', 'Secondary');
app.fire('Motion:arm_right', 'Secondary');
}
else
if(this.weapon_2.tags.has('Stock'))
{
app.fire('Motion:arm_left', 'Primary');
app.fire('Motion:arm_right', 'Primary');
}
}
}
/*animation*/
/*Sprinting weapon specific animations*/
if(Shiftp){
this.sprinting = true;
if(this.weapon_1.enabled == true && this.weapon_1.tags.has('AR')||this.weapon_1.tags.has('SMG')||this.weapon_1.tags.has('LMG'))
{
app.fire('Motion:arm_right_origin', 'on_1'); app.fire('Motion:arm_left_origin', 'on_1');
}
if(this.weapon_2.enabled == true && this.weapon_2.tags.has('Pistol'))
{
app.fire('Motion:arm_right_origin', 'on_2');app.fire('Motion:arm_left_origin', 'on_2');}
}
if(Shiftr){
this.sprinting = false;
if(this.weapon_1.enabled == true && this.weapon_1.tags.has('AR')||this.weapon_1.tags.has('SMG')||this.weapon_1.tags.has('LMG'))
{
app.fire('Motion:arm_right_origin', 'off_1'); app.fire('Motion:arm_left_origin', 'off_1');
}
if(this.weapon_2.enabled == true && this.weapon_2.tags.has('Pistol'))
{
app.fire('Motion:arm_right_origin', 'off_2');app.fire('Motion:arm_left_origin', 'off_2');}
}
if(this.sprinting == false && R)
{
if(this.weapon_1.enabled == true && this.weapon_1.tags.has('AR')||this.weapon_1.tags.has('SMG')||this.weapon_1.tags.has('LMG'))
{
app.fire('Motion:arm_right_model', 'Reload_Primary');
app.fire('Motion:arm_left_model', 'Reload_Primary');
//app.fire('Reload',20);
}
if(this.weapon_2.enabled == true && this.weapon_2.tags.has('Pistol'))
{
app.fire('Motion:arm_right_model', 'Reload_Secondary');
app.fire('Motion:arm_left_model', 'Reload_Secondary');
//app.fire('Reload',20);
}
}
};
Hi @Connor_Briggs!
It looks like the entity you try to clone doesn’t exist.
If you click on the error, you will see the line with the problem in the code editor. You need to check if the code is correct and if the entity you try to clone exist in the hierarchy of your project.