How to have the character switch weapons

Your question should be more specific. Which youtube video are you following? Which part does not work for you? What does your blueprint/c++ code look like? That way people would be able to diagnose the issue you have.

Anyway, a simple multi-weapon design is:

  • Your character should have an array
    of weapons, each weapon bound to a
    key (1,2,3…). The weapon can be
    attached to the character via
    AttachToActor() method.

  • Your character should have a
    CurrentWeapon variable that tracks
    the current active weapon. You want
    to hide all other inactive weapon.
    When an weapon becomes active, you
    un-hide it.

  • Your weapons should derive from the
    same base class that declares some
    common functions such as Fire(),
    AlternateFire(), etc. In each
    subclass weapon you implement these
    functions.

  • You should add debug information,
    such that each time you switch weapon
    by pressing some button, the name of
    the CurrentWeapon is printed out.

1 Like