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"

Referencing Integer in another BP? / casting

I'm trying to get the value of integer from another blueprint PuzzleBlock into PuzzleBlockGrid, I know this question has been asked and answered a thousand times but I've tried all kinds of different objects and none of them work. I just cannot understand the logic behind it, sometimes it's game mode, sometime's player pawn etc. etc. and even when I dont get error the casting still fails. why? Sorry for asking the same question as everyone else but I've seriously tried so many different objects that were recommended in the answers of other posts and none of them worked :( Thanks in advance.

alt text

Product Version: UE 4.21
more ▼

asked Feb 04 '19 at 08:16 PM in Blueprint Scripting

avatar image

16 3 1 2

avatar image rokkie199 Feb 04 '19 at 10:12 PM

I tried https://answers.unrealengine.com/questions/210900/what-object-do-i-cast-in-the-cast-function.html just now too but even that doesnt work, it still prints the string 'hello' indicating that the casting failed.

What am I missing :(

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

1 answer: sort voted first

I just did the exact same thing today and I used BPI instead of casting since I need it for several characters. Even so, the engine tax shouldn't be any higher so it's a possible solution. https://answers.unrealengine.com/questions/871425/view.html

The benefit is that it is easily reusable for any value in any blueprint. If you need to set the value and keep it set you just need a new function with exact same setup for other variables. If it just needs to receive it once you can reuse the same function again and again.

more ▼

answered Feb 04 '19 at 08:25 PM

avatar image

Crowley Caine
693 8 10 16

avatar image Crowley Caine Feb 04 '19 at 09:04 PM

Update to that, instead of "other actor" you can use get player character or whatever you want really.

avatar image rokkie199 Feb 04 '19 at 10:03 PM

I tried looking into it but basically everything you said in that thread went over my head. :( Maybe I'm just too stupid >.< I know I was once able to do this when I followed a guide from youtube but that time I used "cast to player character" or smthing, but that BP doesnt even exist in the puzzle set up and doesnt work.

avatar image Crowley Caine Feb 04 '19 at 10:04 PM

Oh, well you just have to make it cast to YOUR character blueprint. Aka, what you called your character blueprint. The videos have their own names for them.

avatar image rokkie199 Feb 04 '19 at 10:20 PM

but the puzzle template doesnt have character blueprint, my variable that Im trying to reference is in the "PuzzleBlock" BP, (which I've casted into) but it won't work anyway, no matter what I choose as the "object"

avatar image Crowley Caine Feb 04 '19 at 10:24 PM

A character blueprint is a blueprint class, not necessarily a character blueprint, ie playable character, as such. I'm guessing your PuzzleBlock Blueprint is in fact a character blueprint. Without seeing what you're doing it is fairly difficult though. I'd also guess "Get player character" is what you want as the object.


avatar image rokkie199 Feb 04 '19 at 10:37 PM

All I really want is for the casting not to fail, and to be able to read the value of "dollars" int variable, but here are some images of the two blueprints: alt text

alt text

Also I tried using get player character, it didnt work out:

alt text

beginning.jpg (262.3 kB)
end.jpg (252.0 kB)
getplayerchar.jpg (217.0 kB)
avatar image Crowley Caine Feb 04 '19 at 10:50 PM

What does the warning say? Will always fail or something like that?

avatar image rokkie199 Feb 04 '19 at 10:52 PM

'Puzzle Block' does not inherit from 'Character' ( Cast To PuzzleBlock would always fail). [0091.77] Compile of PuzzleBlockGrid successful, but with 1 Warning(s) [in 248 ms] (/Game/PuzzleBP/Blueprints/PuzzleBlockGrid.PuzzleBlockGrid)

Also here's pic: alt text

puzzleblock.jpg (56.9 kB)
avatar image rokkie199 Feb 04 '19 at 10:55 PM

Get owner & get parent actor don't give a warning but they still fail and print the hello string, same with get all actors of class

avatar image Crowley Caine Feb 04 '19 at 11:09 PM

Well the player character will definitely not work there, that's for sure.

What class have you selected when you use get all actors of class?

avatar image rokkie199 Feb 04 '19 at 11:54 PM

Not sure if this answers your question but this is what I did when I attempted that:

alt text

Sorry for taking so long to reply, also, thanks for attempting to help me for so long :3

allactors.png (114.2 kB)
avatar image rokkie199 Feb 04 '19 at 11:58 PM

Whoops, right after posting that picture I realized what you meant, so I tried a few different actor classes, which I hadn't noticed could be changed before, and after selecting Puzzle Block, the cast to finally worked. :3

Thanks for all your help!

avatar image Crowley Caine Feb 05 '19 at 01:35 AM

No problem, glad it worked. Feel like we should've figured this out sooner haha

Easy to miss that one.

(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