0
\$\begingroup\$

I want to create a modular weapon system. I already got most of it working, but I wonder how to make an improvement.

Weapons in my game have different firing modes (semi and auto) and "bullet" modes (projectile and hitscan). Each weapon is it's own blueprint, and there I can select proper one in editor, so for example an Uzi would be auto / histcan, while a rocket launcher would be semi / projectile. (the firing mode actor gets created at spawn from the class selected in editor).

I want to make it easier to edit by giving the weapon some variables, like spread and projectile blueprint. But not all of the variables apply to all the types of weapon...

TLDR: Can I create / show different variables in the editor, depending on other variables? If I choose projectile type of weapon, can I also select the projectile type, but not show the option if I chose hitscan?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Yes you can, Take a look at EditCondition meta specifier in UPROPERTY.

for example:

UPROPERTY( Category=Location, EditAnywhere )
uint32 bUseOffset:1;

UPROPERTY( Category=Location, EditAnywhere, meta=(EditCondition="bUseOffset") )
FVector Offset;

In this case the Offset will be editable only if bUseOffset is true.

Please also refer to: UE4 documentatoon

\$\endgroup\$
3
  • \$\begingroup\$ Thank you very much. I will check it out in the morning! \$\endgroup\$
    – lilKriT
    Apr 21, 2019 at 3:38
  • \$\begingroup\$ This is a link-only answer. It would be better if we had an answer which explains this itself instead of just linking users to another website which might one day break. \$\endgroup\$
    – Philipp
    May 10, 2021 at 7:20
  • \$\begingroup\$ There's something similar to do it via blueprints also? \$\endgroup\$ Oct 7, 2021 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .