Skip to main content
Updated to use both combined methods from me and the original author of the question
Source Link

You can use a RayCast for weapons, this allows all weapons to use one set of attributes, so range etc. Now you would have a melee weapon use the range, but set it to set 0.5. This would give the melee weapon a low range, making it seem like its melee (This would be played with allot btw) then from this your weapons all use the same attributes. It saves on creating methods for different types of weapons. Most games use a system like this, as it is really easy to create new weapons on the fly. As for stab and slash and slash just use different animations, and if the player uses that melee type, i.e right clicks a knife to stab, the damage would be different but the animation longer.

The above is the original comment i made

To expand on this comment, You can have one set of variables, say range and damage and ammo, then set the variables according to the weapon. For melee just set the ammo to something like -1 (Should cause it to just be unlimited) and the damage for each mouse click to be different, and play different animations.

The raycast will handle most of the calculation for you, you just gotta tell it what to do haha.

Hope this helps

Edit

[Combined data suggestion] by @Ryanwhite and @ronscript

Blue line is area of effect angle covered
Green line is distance covered
Red point is the target point

enter image description here

public class WeaponComponent implements Component { 
    public Ray ray // to handle collisions
    public float aoe; // This would be the range of different weapons, you could stagger them for range drop etc.
    public float aoeAngleCovered;
    public float aoeAngle
    public Ammo[] // Set ammo to 0 and give exception to melee weapons to ignore ammo.
}

You can use a RayCast for weapons, this allows all weapons to use one set of attributes, so range etc. Now you would have a melee weapon use the range, but set it to set 0.5. This would give the melee weapon a low range, making it seem like its melee (This would be played with allot btw) then from this your weapons all use the same attributes. It saves on creating methods for different types of weapons. Most games use a system like this, as it is really easy to create new weapons on the fly. As for stab and slash and slash just use different animations, and if the player uses that melee type, i.e right clicks a knife to stab, the damage would be different but the animation longer.

The above is the original comment i made

To expand on this comment, You can have one set of variables, say range and damage and ammo, then set the variables according to the weapon. For melee just set the ammo to something like -1 (Should cause it to just be unlimited) and the damage for each mouse click to be different, and play different animations.

The raycast will handle most of the calculation for you, you just gotta tell it what to do haha.

Hope this helps

You can use a RayCast for weapons, this allows all weapons to use one set of attributes, so range etc. Now you would have a melee weapon use the range, but set it to set 0.5. This would give the melee weapon a low range, making it seem like its melee (This would be played with allot btw) then from this your weapons all use the same attributes. It saves on creating methods for different types of weapons. Most games use a system like this, as it is really easy to create new weapons on the fly. As for stab and slash and slash just use different animations, and if the player uses that melee type, i.e right clicks a knife to stab, the damage would be different but the animation longer.

The above is the original comment i made

To expand on this comment, You can have one set of variables, say range and damage and ammo, then set the variables according to the weapon. For melee just set the ammo to something like -1 (Should cause it to just be unlimited) and the damage for each mouse click to be different, and play different animations.

The raycast will handle most of the calculation for you, you just gotta tell it what to do haha.

Hope this helps

Edit

[Combined data suggestion] by @Ryanwhite and @ronscript

Blue line is area of effect angle covered
Green line is distance covered
Red point is the target point

enter image description here

public class WeaponComponent implements Component { 
    public Ray ray // to handle collisions
    public float aoe; // This would be the range of different weapons, you could stagger them for range drop etc.
    public float aoeAngleCovered;
    public float aoeAngle
    public Ammo[] // Set ammo to 0 and give exception to melee weapons to ignore ammo.
}
Source Link

You can use a RayCast for weapons, this allows all weapons to use one set of attributes, so range etc. Now you would have a melee weapon use the range, but set it to set 0.5. This would give the melee weapon a low range, making it seem like its melee (This would be played with allot btw) then from this your weapons all use the same attributes. It saves on creating methods for different types of weapons. Most games use a system like this, as it is really easy to create new weapons on the fly. As for stab and slash and slash just use different animations, and if the player uses that melee type, i.e right clicks a knife to stab, the damage would be different but the animation longer.

The above is the original comment i made

To expand on this comment, You can have one set of variables, say range and damage and ammo, then set the variables according to the weapon. For melee just set the ammo to something like -1 (Should cause it to just be unlimited) and the damage for each mouse click to be different, and play different animations.

The raycast will handle most of the calculation for you, you just gotta tell it what to do haha.

Hope this helps