It’s for a shoot bullet script. We’re making an fps game in class and I copied the script provided to us. Seemed to work on everyone else but mine keeps saying it cant read ‘teleport’
Here’s the shootbullet script:
var ShootBullet = pc.createScript(‘shootBullet’);
ShootBullet.attributes.add(‘bulletEmitter’, {
type:‘entity’
});
// initialize code called once per entity
ShootBullet.prototype.initialize = function() {
};
// update code called every frame
ShootBullet.prototype.update = function(dt) {
if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
//retrieve the bullet template from the asset window
var BulletFromTheAsset = this.app.assets.get(140973292);
//make the bullet appear on stage
var BulletInstance = BulletFromTheAsset.resource.instantiate();
//make the bulletInstance a child of the root
this.app.root.addChild(BulletInstance);
//get the position of the bulletEmitter
var BulletPosition = this.bulletEmitter.getPosition();
//teleport the bulletInstance to the bulletPosition
BulletInstance.rigidbody.teleport(BulletPosition)
//retrieve the Vec3 coordinates, which refers to xyz axis (gizmo)
this.force = new pc.Vec3();
//retrieve the z axis
this.force.copy(this.entity.forward);
//scale the z axis to 800
this.force.copy(this.entity.forward).scale(800);
//apply force to the BulletInstance
BulletInstance.rigidbody.applyForce(this.force);
}
};
Please help