I am having a heck of a time understanding this.

I am not new to object languages I have programmed in C base languages in the past but I am very new to the blueprint system and things that in my mind should just work never do I am so at a loss. In this example I am attempting to retrieve the boolean variable “driving” which is set to true in the On possess Script on my Third person character BP. SET var Driving is on the end of the enter cockpit as the last action. and ticked to be set to true when I Hit E to enter the cockpit essentially.

I have made the variable public in both of the references to it within 3rd person and within the anim blueprint.

I have set up the Bone transform in the animgraph and verified it does work be disconnecting and reconnecting the False return seeing immediate change to the object. The problem I am having is I have tried doing Cast to, I have tried get all actors of class attempting to pull the Var from an array and a couple other little methodologies I could think up and nothing seems to work. I just cant seem to get the value of that boolean to properly set.

I’m not stupid but clearly ignorant of whatever I am doing wrong. Help!

Here is my current setup for returning and setting local Variables in a function.

Please forgive my particular organization style I make it pretty when it works and tend to smash things together as blocks of minor functions until I get something debugged.

Hey @Korwinthale!

So what I’m going to need on this one is a few things:

Where is this function? From what I understand it is on the Animation Blueprint on something, but I don’t know what. Is it for the ship or the third person character?

Secondly, WHEN is this function? It’s possible that it is getting called before the value is set to true in the execution line.

Get that stuff back to us and hopefully we can get this ironed out!

1 Like

I have it setup Thus, On my TPCBP I have an input event within the event graph.

The vehicle has within it’s event graph this.

In The AnimBP Event grap I just have the function fired off by the
event update animation node.

The function is within the anim

Is there more than 1 instance of the TPCBP in the scene?

No, the test scene has only the vehicle, the player start location and a few blue boxes to kick around.

Sounds good. Just to clarify, while PIE (play in editor), this shows only a single instance, right?

image


And this definitely executes?

As in, you’ve placed a breakpoint on a node (F9) / observed execution flow (as in your very frist image) or can simply visually confirm that you are, indeed, possessing a hulking mech instead of a puny human pawn?

Yes and yes, Also I have been fiddling around and this works… well… Sort of it is throwing errors but in game the cockpit door goes from open to close and reverses when I exit . I’ll have to worry about the interps later but when I fire this script it gives an Array returns a null value error as if it can not retrieve the Variable yet… clearly it is retrieving the variable because it is working… sigh ha!

But the reason I am throwing in the call to the vehicle for the original rotations etc is to Interp them later and get a smooth opening and closing motion but I’ve stripped all the fluff out of what I’m doing attempting to figure out what is wrong. Again I am new to this blueprint system heh.

And yes I possess the mech stomp around kick boxes off the map I just wanted a cool cockpit door animation lol.

I did not mean to mark this stupid thing solved I misclicked and I dont know how to fix it, Edit: Fixed it lol

Ah, there’s a misconception here that the “Driving” Variable from the target is == the “Driving” Variable on the ABP.

If it helps, this observation is unfortunately incorrect. You are pulling the ABP’s Driving variable state- which is set default to False. If it is receiving a null signal, it uses its current state and pushes that through, it is not retrieving the TPC’s Driving variable.

One option you could do, as you have a grasp of how to set a variable on another actor-

Give the Mech a bool variable of “BeingDriven”. When the player boards, set “Being Driven” on the mech to True, or simply have it match the “Driving” Bool on the player, much like your exit code sets driving on the player to False.

Then, on the ABP, you can use “TryGetOwner” to get the ABP’s owning mech actor, cast to your mech, then as the mech Set your ABP Driving bool == the mech’s “BeingDriven” bool.

For performance you can also just use the BeginPlay on your Mech ABP to TryGetOwner-> CastToMechActorBP and then set that as variable for any use throughout your ABP. :slight_smile:

While I am testing this, Is it possible, Intelligent and or appropriate to create like a VarStore BP Where you just drop the actor invisible into all of your scenes and use it to swap vars ?

Generally, no, it’s somewhat unnecessary. There are edge cases but in Unreal Engine it’s generally unwarranted. The GameMode can be used for this in some cases, but for this, you don’t need anything besides the two actors.

Using “Sphere/capsule/line Trace by channel/for objects”, along with == Class nodes and IsValid? macro checks you can pretty reliably get information on and references to specific things in the environment on the output of those Sphere/capsule/line trace hits without using things like “GetAllActorsOfClass” which are pretty hurtful to performance as they scan every single actor each time they’re called.

I am still not able to get this working properly. I think I need to take a break lol.

Let us know what your code looks like and maybe we can add/subtract some pieces to get it in working order! If I get to see it I’ll explain how and why any changes are added as well, the important part is you learning not the part where it gets done! :slight_smile:

yeah I tried it the way you said and was still getting that weird null value error but the weird part is Calling the exact same things in the Character graph works but doesnt allow me to adjust the bone transform in the anim because I just can not get the variables there. On another odd note… My other animation sets work just fine passing variables and such so I am totally at a loss. I have a walking animation blend that calls speed, vector etc etc and all of that works fine. When I attempt it tomorrow again I will post the progress lol.

Wait, what is the issue again? I think we’re getting away from the original issue. I thought it was that the value wasn’t passing through, but if it is opening and closing then obviously it is- I must have overlooked that. Then we talked about a few other things. Is it now specifically that it is giving a Null Reference Exception?

A quick way to tell where your null is happening- when you look at your NRE you can see a little magnifying glass on each level, clicking the item there will take you directly to where the issue is on the BP, depending on which one you click.

1 Like

For some reason either the variable doesn’t come through at all or when I do manage to get the cockpit opening and closing it’s throwing null value errors even though it’s opening and closing off of the branch and it basically can’t do that unless the variable is coming through.

sigh

Sorry this is Just impossibly frustrating … Things either work or don’t with no logical reason. Why can’t we just set a dang global variable …