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"

Blueprint cast question

Hi, I'm working on a simple weapon base currently. I just added the first weapon which is a child of the base. I'm attempting to access a variable called "WeaponSound" in the weaponbp. I'm casting to the weaponbp to read the value of WeaponSound so it can play the weapon-specific sound when it fires.

Here is what I have so far: https://i.imgur.com/hIzdBSL.png

I have tried using "self" as a reference, it doesn't return the yellow warning, but it still fails every time. I've tried just about every object/reference I can for the object input on the cast but nothing is working. Thanks in advance! :)

Product Version: UE 4.18
Tags:
more ▼

asked Feb 08 '18 at 09:57 AM in Blueprint Scripting

avatar image

austin1346
3 3

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

1 answer: sort voted first

Your 'gun' variable looks like it is just a skeletal mesh actor. What is the parent class of the 'm1garand_bp'. Your 'weapon_base' class is just an actor, so casting to 'm1garand_bp' will also fail every time.

Where do you spawn or create your 'm1garand_bp'? You will need to store an instance of this somewhere and find it. You could try 'GetAllActorsOfClass using 'm1garand_bp' as the class, just to make sure you actually have one of them somewhere?

more ▼

answered Feb 08 '18 at 10:31 AM

avatar image

Dune
1.9k 53 40 200

avatar image Jin_VE Feb 08 '18 at 08:28 PM

This is correct. Might be best to point austin to a good tutorial video.

(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