Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Using a blueprint variable?

Hey! I am trying to create an Inventory system. I was thinking about making a new class for each weapon, as I am trying to create a rather diverse arsenal and not all weapons will be using the same type of function to fire. The problem is, that I am only aware of single classes being available as variables. Am I wrong? Is there anything I could do to adjust my scripts etc.? Any advice is appreciated. Thank you in advance!

Product Version: Not Selected
more ▼

asked Jun 20 '14 at 07:12 AM in C++ Programming

avatar image

174 44 39 49

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You can use inheritance for this. Providing all your classes inherit from a common base class (eg AWeapon). Then you can have in your inventory:

 TArray<AWeapon*> Weapons

Your AWeapon class would declare a virtual function called fire:

 virtual void Fire() = 0; // the = 0 just means you don't have to specify how a weapon fires

Then you call the Fire method and the relevant method will be called.

more ▼

answered Jun 20 '14 at 08:17 AM

avatar image

651 44 59 91

avatar image Borzi Jun 20 '14 at 09:14 AM

Interesting....although I have no idea how I will specify and apply this Fire() thing, this looks like a good method. Thanks.

avatar image thk123 Jun 20 '14 at 09:45 AM

Look up class inheritance in C++

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question