i kept the wall files, because they might come in handy
@Thebosser_24 From this point please create a new thread specific to your issue. We should not be using this one anymore because it is off topic. Can I mark this as solved?
i need to reload 2 guns, how would I do that? i put the lines into the function, and I need some sort of way to have it count the Rounds as separate from the other weapons
i was looking back, how would i go about to having an Ammo Count, and a Reload count, would this go into my movement script, or into a new script made entirely for my weapon.
@Thebosser_24 This could be done several ways. I would however suggest separating this into either a weapon script or create a game manager script that holds this information and updates a UI. I think that there may be some questions/answers about this on the forum.
i have 3 weapon scripts (all empty) Pistol, Sniper, AR
I currently have my shooting, reload, and ammo into my FirstPersonMovement script
@Thebosser_24 This is just an idea as I had stated above. If you make one gun script you could use attributes with the script to configure each weapon. Like<
GunShoot.attributes.add('player', { type: 'entity' });
GunShoot.attributes.add('camera', {type: 'entity', description: 'Optional, assign a camera entity, otherise one is created'});
GunShoot.attributes.add('muzzleFx', { type: 'entity', description: 'Muzzle flash particle system' });
GunShoot.attributes.add('bulletFx', { type: 'entity' , description: 'Bullet effect system' });
GunShoot.attributes.add('impactForce', { type: 'number' , default: 100, description: 'Impact force' });
GunShoot.attributes.add('Automatic', { type: 'boolean' , defalut: false, description: 'Fully automatic or semi-automatic'});
GunShoot.attributes.add('magSize', { type: 'number' , defalut: 15, description: 'Size of magazine'});
GunShoot.attributes.add('firedCount', { type: 'number' , defalut: 15, description: 'Counter to keep track of how many fired'});
Using a generic script that would be configurable through attributes would cover any weapon you would want to use.
I would also suggest that you move the firing(Mousedown) into the generic gun script because each has a trigger.
I have covered a lot of this in the WeaponTest example here.
@Thebosser_24 I have updated this project to add a simple bullet management system like the one I believe you are looking for. Study the gun-shoot script to see how it works.
so have taken out some important parts for me to implementâŚ
am I missing something
GunShoot.attributes.add('bulletCntr', { type: 'number' , default: 0, description: 'Current bullet count'});
// Find the text element to use for update
this.ammoText = this.app.root.findByName("ammoCnt");
// Handle reload
if(this.app.keyboard.wasPressed(pc.KEY_R)) {
console.log("Reload Hit");
// Reload Magazine
this.bulletCntr = this.magSize;
}
// Update Ammo text
this.ammoText.element.text = this.bulletCntr + '/' + this.magSize;
};
// Handle mouse down event
GunShoot.prototype.mouseDown = function(e) {
// Check for Mouse left button
if(this.entity.enabled && e.button == pc.MOUSEBUTTON_LEFT) {
if(this.bulletCntr != 0) {
// Process action
this.shoot();
// Decrease bullet count
this.bulletCntr--;
}
}
@Thebosser_24 I am not sure what the context of the question is. I had a look to the link to your project above and I am not locating the code above. Are you getting some type of error?
i havent implemented it yet, becuase ima do it slowly so i dont break my script, and it will be easier to find errors
no errors
Iâm still learning, so ima try to do this one step at a time
@Thebosser_24 OK Just wasnât sure what I should respond to. Keep going at that pace. One step at a time is easier to locate when a problem occurs.
so i have added them in and I am having problems with my bullet script, I believe its unrelated to the script I added, but it doesnât work i believe its the same problem as before, but i cant tell, and i deleted my other game, so i donât know
i figured it out, i just need to fix this line, it says Event is Depricated
if (event.button === pc.MOUSEBUTTON_LEFT) {
the script works, because I changed to the space bar, and it works, I just need to fix this line
I fixed it by myself