ok so i kinda got what i want in here so far. Shooting reloading (Although if you reload you cant shoot anymore) its got the basics of what i need heres the project:
https://playcanvas.com/project/612040/overview/animation-test
I will not be releasing a build until i can fix this code here:
var AnimationBlending = pc.createScript('animationBlending');
AnimationBlending.states = {
reload: {
animation: 'anim_ak47_reload.json'
}
};
// initialize code called once per entity
AnimationBlending.prototype.initialize = function() {
this.blendTime = 0.2;
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.keyDown, this);
this.app.keyboard.on(pc.EVENT_KEYUP, this.keyUp, this);
};
AnimationBlending.prototype.update = function(dt) {
var AudioEntity = this.app.root.findByName('reloadSound');
if (this.app.keyboard.wasPressed(pc.KEY_R)) {
this.setState('reload');
isReloading = true;
AudioEntity.sound.play('reloadSound');
//this.script.gun.enabled = false;
}
/* if (this.state === false) {
this.scripts.enabled = false;
}*/
};
AnimationBlending.prototype.setState = function (state) {
var states = AnimationBlending.states;
this.state = state;
// Set the current animation, taking 0.2 seconds to blend from
// the current animation state to the start of the target animation.
this.entity.animation.play(states[state].animation, this.blendTime);
};
/*AnimationBlending.prototype.keyDown = function (e) {
if ((e.key === pc.KEY_R) && (this.state !== 'reload')) {
this.setState('reload');
}
};*/
I am still working on this looking for a way to let the player shoot after reload ‘R’
also i am waiting until i can get the AI to die which is like impossible rn
if(bullet.entity.tags.has("AI")){
kills++;
bullet.entity.destroy();
Doesnt work i am still working with it and im busy 90% of the time doing something else if anyone has any suggestions or im missing something or if you even want to help please show some feedback love in the comments
Thanks,
Nathan Hawkins