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. 

Behavior Tree Tutorial: failure to cast

I was working on the Behavior Tree Tutorial provided by the Unreal Engine Documentation and I got to this point: https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/QuickStart/13/index.html

I cannot find anything different about my code, yet I see this and I am sure it is why my AI never stops chasing me: alt text

Does anyone know why it is giving me this note and/or why my AI never gives up chasing no matter how far away I am?

Product Version: UE 4.10
Tags:
errorimage1.jpg (100.4 kB)
more ▼

asked Feb 03 '16 at 01:01 AM in Blueprint Scripting

avatar image

Ironmonger42
9 7 6 8

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

1 answer: sort voted first

2 Different issues here. That error is because the function you wrote is expecting a return, however there is a path that could lead to possible case where nothing is return. To fix this, just connect cast failed also into the return exec node (and maybe include a debug print message like 'cast failed' or something).

The reason this may never be triggering may have to do with your 'TargetToFollow' variable. Have you verified that this variable is actually set in game? When you run your behavior tree in game, check the details panel of the tree to see what was assigned to that variable. You may have already done this, but hard to say what else could be the issue without seeing the tree.

more ▼

answered Feb 03 '16 at 04:55 PM

avatar image

paradoc
1.2k 49 31 86

avatar image Ironmonger42 Feb 04 '16 at 06:40 PM

I tried connecting like you said: alt text But now i'm seeing this error: alt text Do you know what the error is? Where should i be looking? I can't find anything i'm doing differently than the tutorial...

errorimage3.jpg (57.8 kB)
errorimage2.jpg (174.8 kB)
avatar image slarti Feb 04 '16 at 06:54 PM

As paradoc said, you should connect the "Cast Failed" pin directly to the return node, not to the "Set Variable" node. The "Print String" may stay but when it is connected to the "Set Variable" node, it tries to set the variable on the object that could not be cast to a "Follower_AI_CON" and thus the variable cannot be set on that object resulting in an error.

avatar image Ironmonger42 Feb 04 '16 at 08:51 PM

I connected Cast Failed to return node and I'm still getting the error. If you look back at the error list image the problem seems to be the GetBlackboardValueAsActor node, which is only connected to TargetToFollow, not the AI_CON_Ref, so i'm beginning to think that the cast failing or not is not the issue.

avatar image paradoc Feb 04 '16 at 09:35 PM

check out the next page of that tutorial and verify your decorator 'Close Enough' actually has something assigned to it in 'TargetToFollow' (part 2 of the original answer above). the error your getting means it can't find any value for that blackboard key. here's the link: Blackboard Data notice how in that image 'TargetToFollow' is set to 'TargetToFollow' from their blackboard data.

(but also include what slarti says above as well in terms of casting)

avatar image Ironmonger42 Feb 05 '16 at 04:57 PM

this is what I see when I click on the Close Enough node: alt text

errorimage4.jpg (57.1 kB)
avatar image slarti Feb 05 '16 at 09:23 AM

In addition you may want to use the "Is Valid" blueprint node and a branch to check if the return value of GetBlackboardValueAsActor returns a valid value or ´null´. This does not fix the problem that the value is null in the first place but you can add an error message to the non-valid branch to see whats going on there.

avatar image Ironmonger42 Feb 05 '16 at 05:02 PM

I did as you suggested: alt text and it is in fact printing out "is not valid" from the print statement a couple of times once it gets far enough away. Does that help pinpoint what i need to change?

errorimage5.jpg (93.1 kB)
(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