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"

What object do I cast in the cast function?

My problem seems to be quite a simple one, as my casts ALWAYS fail and I think its because I just dont really know what object I am supposed to cast.

I am usually making a reference to self.

Example:

I want my weapon to start firing when the Action "InputActionFire" is called by the hero, and therefore I made a tick and then casted to the hero class (object self). After that I "got" the variable I set aside for that and checked it with a branch.... the cast fails tho :(

Thanks in advance

Product Version: Not Selected
Tags:
more ▼

asked Apr 13 '15 at 01:15 PM in Blueprint Scripting

avatar image

henrik_baumann
79 15 13 19

avatar image Narghile Apr 13 '15 at 01:19 PM

So your pawn is casting to your pawn or did I miss understand you?

Narg

avatar image DanzigLucifuge Apr 14 '17 at 01:14 PM

If I could find one goddamn decent explanation of casting I would have figured this out about a month ago. For one thing whatever your saying doesn't work. The array goes somewhere, then you have a node out of that into "object". Well how do I even get that. How do I get from out actors to object? I'm becoming more and more convinced they make this hard on purpose so no one will compete with unreal tournament.

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

3 answers: sort voted first

Howdy Mate

WHen you cast, you cast to ANOTHER BP, not your own, as the Variable is already there.

Here is a quick example.

alt text

BP1 - I made a Variable

alt text

If I Want it, just drag it out.

alt text

In BP2, if I need it I cast.

alt text

capture.jpg (17.5 kB)
capture.jpg (12.8 kB)
capture.jpg (21.8 kB)
capture.jpg (39.2 kB)
more ▼

answered Apr 13 '15 at 01:33 PM

avatar image

Narghile
1.7k 74 38 109

avatar image henrik_baumann Apr 13 '15 at 01:47 PM

works thanks so much yea I am still a started and realised that making EVERYTHING in the Hero class is not very smart ^^ you're my saviour

avatar image lazerwarrior Jul 26 '18 at 05:33 AM

when I do that it comes up with this: (The current value of the ' Array ' pin is invalid: Array inputs (like 'Target Array') must have an input wired into them (try connecting a MakeArray node).)

avatar image samohickey Mar 05 '19 at 04:07 AM

I think that this is the hardest concept to grasp, yet seems the most common sense, with object oriented programming.

A lot of the struggles I have when I am trying to code on my own go back to casting. I know I need to cast to get a reference to another BP, I know that I can make a reference variable to call from once I have casted... But... Before you can truly cast... You need that 'Object' input taken care of.

Easy enough when it's just 'GetPlayerController' or 'GetPlayerCharacter'... But when you try to reference one of your custom objects... That's where my brain shuts down.

Narghile, this helps me so much with so many situations. Thank you! Great post!

avatar image Nebula Games Inc Mar 05 '19 at 05:22 AM

For more in depth look at this subject check out the first video about casting and the 2nd last one about creating references I think it will help clear some stuff up if you are having any other troubles

Unreal Engine 4 Beginner Tutorials: https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy

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

answered Apr 13 '15 at 01:28 PM

avatar image

Jurif
632 26 15 45

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

when I do that it comes up with this (The current value of the ' Array ' pin is invalid: Array inputs (like 'Target Array') must have an input wired into them (try connecting a MakeArray node).)please help

more ▼

answered Jul 26 '18 at 12:23 PM

avatar image

lazerwarrior
1 1

avatar image Nebula Games Inc Jul 26 '18 at 02:32 PM

post a screen shot of what you are talking about

(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