I can't Cross Reference/Call Blueprints Into Other Ones

So for my blueprints, in the photo below, I have code (For VR) when you bring a food item to your VR pawn character, it will overlap the trigger box, and increase the hunger amount by 20 by calling the
Increase Hunger" function in the “Whiteboard” actor.


However, I get an error each time saying it doesn’t like my “Promote to Variable” action.

image

Whiteboard code (Contains widgets that have bars in them in material form.)

Why does it do this and can I make it stop?

Hey @Villager-13!

It’s because your “Hunger Whiteboard” variable doesn’t have a reference, in essence, you have made a square hole, but no square peg is in it (the peg being your Whiteboard actor in the world).

One way to do this would be to use “GetAllActorsOfClass” but that could be costly.

What would be better:

On the Whiteboard BP, use “GetPlayerPawn”, cast to your VRPawn Blueprint, and “As VRPawn”, SET Hunger Whiteboard with “self” as the input. This will only work if this is the only Whiteboard Actor in the level. :slight_smile:
Hope that helps! Let us know how it goes!

Thank you so much for your response!
For some reason, I still get the error when I put this in my Whiteboard BP.


I have ALSO tried this in my VRPawn in addition to the WhiteBoard code you listed above. It gets rid of the error, but doesn’t work.

If this is ON your VRPawn, you’re just telling the whiteboard variable to set itself as itself. Unfortunately, this does nothing. :frowning:

You definitely want to take off the “Then 3” on tick- you don’t want to re-cast and re-set a variable actor on tick- I don’t know if it’s contributing to your problem (it could be), but it’s definitely bad news down the line and resource intensive doing it 60 times/second. Just take the beginplay line off tick.

Additionally, add a printstring to “CastFailed” on the cast to VRPawn. Because if the cast fails, we know it isn’t getting through, so you know for sure that the Hunger Whiteboard variable isn’t being set.

I am thinking that is what is happening on the Overlap code for (FoodEat_Box) - I think the cast is failing and so it isn’t continuing to the “IncreaseHunger” function, so the reference isn’t called, so there’s no error.

Look into that and let us know what you find out!

Hello, sorry to get back late. But you are CORRET! Both casts to my VR pawn are failing. It may be due to the OBJECT my ‘Cast to VRPawn’ is connecting to.
image

However, I don’t know what I SHOULD set the object as. ‘Self’ and ‘Player Character/Controller’ don’t work either.
I also tried something to see if the “Hunger Whiteboard” reference is the issue. I set it as whenever I teleport, it increases my hunger. And it worked! Which means my whiteboard reference isn’t the problem.

So then, what should be done with my Object in my VRPawn cast to make it work?

Hmm…

The only way that Cast should fail, is if the player is not playing as a VRPawn. GetPlayerPawn returns the controlled pawn at 0, and if there is not a pawn registered to that controller… then you have a failure.

So firstly, check to make sure the player is playing as a “VRPawn.”

Secondly, check the parent class of “VRPawn”. If it is not “Character” or “Pawn” we found the issue.

Also, the “Hunger Whiteboard” reference can still be a problem, unless you are calling the hunger increase on this same blueprint. But let’s get this cast situation fixed first.

Figured stuff out!

1 Like

What did you do? If you could let us know for future answer seekers, that would be great! Communication between actors is a difficult topic for most to wrap their heads around, and all the information we could get on that topic is SO valuable here as a learning tool!

Let us know! :slight_smile: