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"

Problem with casting to a blueprint

Hello,

So I'm trying to cast to a blueprint called myCharacter. Within that blueprint, I have a variable called marker1Exists.

I'm trying to write the number '1' with my HUD, if marker1exists.

alt text

However, the moment I test this and hit the play button, I get 'Cast Failed' continuously appear. Am I doing something wrong?

Product Version: Not Selected
Tags:
castfailed.png (116.8 kB)
more ▼

asked Dec 09 '14 at 02:03 AM in Blueprint Scripting

avatar image

ShrewGlue
444 99 84 108

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

2 answers: sort voted first

Maybe i don't understand from which variable you want to cast to MyCharacter, but try: Right click -> Get Player Character >>> Cast to MyCharacter (so instead of "Casted My Character" node you'll have "Get Player Character") Sorry if i'm unclear, it's late here :) Good night.

more ▼

answered Dec 09 '14 at 02:10 AM

avatar image

Slavq
2k 157 153 209

avatar image ShrewGlue Dec 10 '14 at 09:52 PM

Thank you! This works. Do you think instead of using 'get player character', 'get player controller' would be a better idea?

avatar image Slavq Dec 11 '14 at 01:18 PM

It depends where you have this "Marker1Exists" variable. If it's in your player class, then use Get Player Character, because from there you can cast it to... Your player class (which is of "Character" type)

So if this variable would be (for example) in your player controller class, then Get Player Controller -> Cast to "YourPlayerControllerClass" - because you need to access an object of this class. To undestrand it better, i recommend to read a little about some object-oriented programming things, like classes, interfaces, etc. Example: https://www.youtube.com/watch?v=ABRP_5RYhqU Blueprints are classes - and they work practically in the same way. (because it's like a regular programming, just using nodes instead of lines of code :) )

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

As the previous poster said, you must make sure that 'Casted Character' references a valid Character. It should point to an instance of MyCharcter or one of its sub-classes. If your aim to to get a reference to your-own player, then use GetPlayerCharacter node as @Slavq sugested.

more ▼

answered Dec 09 '14 at 03:04 AM

avatar image

mindfane
3.4k 154 52 271

(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