x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Base Weapon Structure

I'm new to blueprints, and coding in general but I feel like I'm finally making progress. I've searched the forums but I can't find anything specifically answering my problem. I'm having some trouble with inheritance and setting up my weapon blueprint. What I want to do is have a base weapon class that can then have different types of weapons, rifles, knives, etc. Inside the base rifle class I would have an array of rifles. The problem is the only way I know how to call an event from a child object is through casting. I want the base weapon blueprint to not care what child it has, but still be able to fire, and have the child decide the behavior. I thought about using enums like what's in the picture, but I don't know how to accomplish something like that. I'm open to suggestions. The top part of the picture is the player event graph, the bottom is the base weapon.

Question: The idea is the base weapon should be able to fire, then the children of base weapon set the behavior. What method of communication through blueprints should I use to accomplish this.

alt text

Product Version: UE 4.10
Tags:
more ▼

asked Dec 02 '15 at 02:52 PM in Blueprint Scripting

avatar image

Woku
8 2 3 4

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

1 answer: sort voted first

You can define your custom events in the parent class, then override them (fill them with content) in the child classes. Basically, InputActionFire calls FireWeapon for all weapons, but the event will do different things for Rifles and Knives.

more ▼

answered Dec 03 '15 at 10:05 AM

avatar image

erinacea
1.8k 69 28 113

avatar image Woku Dec 03 '15 at 10:47 AM

Oh, I think I understand now, so I don't even need the switch statement in the bottom. Thanks!

(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