How do I know what target to attach to a vector variable from my PB_ThirdPersonCharacter event graph in another Blueprint?

How do I know what target to attach to a vector variable from my PB_ThirdPersonCharacter event graph in another Blueprint?

Here is the variable being set - Bullet Line Trace Impact Point

and here is the variable in a different blueprint (I had to untick context sensitive to get this to show, which is probably an indicator that i’m going about this the wrong way)

So, I would like to use the vector info to control something in another blueprint.

I am super new to Unreal (4 days!) so if you could explain in detail, or with why, that would be really helpful.

Thanks

Yep, when the context sensitivity option is ticked, it shows all the possible nodes you can attach to a pin (when you drag a pin out and release it on an empty space) and all the possible nodes you can use inside a given blueprint class (when you right click on an empty space)

To access a variable from another blueprint, you’d need to use the Cast To node. Simply right click on an empty space, type in “cast to”, and then type in the name of the blueprint that you wanna cast to. Once you have it, you can drag any variable that was created in that blueprint by dragging out it’s blue output pin (which should be named something like As Example_BP) and releasing it on an empty space. Then a menu should pop up where you can type in the name of the variable you wanna get, and click on it. Now, the Cast To node also has an input pin named “Object”, and what you should plug in there depends on what you’re casting to. For example, if you’re casting to the player character’s blueprint, you’d need to plug in the Get Player Pawn node in there. If you’re unsure of what to plug in there, you can just use the Get All Actors of Class node. Get that node, select the same blueprint that the Cast To node is set to from the dropdown menu under the purple Actor Class pin of the Get All Actors of Class node, then drag out the blue Out Actors pin of that node, release it on an empty space, search for the Get node, get it, and leave it’s index as 0. After that, you can plug in the Get node’s output pin into the Object pin of your Cast To node.

Here’s a visualization:

Hope this helps! :blush:

Assuming there is only one PB_ThirdPersonCharacter and you are possessing (controlling) it, any blueprint can:


I’d strongly mildly recommend staying away from the Get (All) Actor of Class nodes, at least for now. While useful, abusing them or using them incorrectly leads to development of some bad coding practices.

1 Like

I also don’t recommend it btw, just mentioned that since it’s currently unknown which blueprint class OP is trying to cast to. You’re right though that’s probably the case, that was also my guess.

I bet it’s just the player BP - the controlled character - but who knows. I have now edited my post to be less definitive ;p


here is the variable in a different blueprint

@TARS_Endurance Whenever you get issues with BP comms, do tell which BP communicates with which one, where they are and so on. Consider including why this needs to happen or what the scenario is. Often there are neater solutions that do not require hard casting like that. And you’ll get a straight answer rather than us trying to stumble in the dark :innocent:.

1 Like

thanks @Everynone @VisAgilis for your replies! It was my first post, and in the time it took for the post to get approved, I not only worked it out but ended up changing my requirements!

Perhaps you can answer this next (I assume) simple problem. I’ll try to give more detail as you suggested.

I have a third person camera line trace to the centre of my screen for a fixed crosshair (called Dynamic Crosshair because it changes size).

I have a line trace running from the gun to the centre of the screen for a non-static crosshair that will show the player that their bullet will be blocked by an object in front of them like so (a crossair will go where the green hit box it)

My code for these looks like this:

My third line trace is for my actual bullet trajectory. and is sut up in the the picture below.

Now, here lies my problem:

The bullet lline trace input for the end point takes the hit point from the non-static crosshair, then adds a clamped random range based on the character’s speed and stance to adjust acuracy.

Everything works exactly as planned except one thing. The random range affects all three axis, meaning sometimes the line trace falls short of the intended hit marker. (it moves the bullet slightly left, right, up, down, but also forward - not an issue - and back. This is in the picture below

I need to increase the distance of the line trace without affecting any other direction, and I can’t for the life of me work out how.

The start point it the bullet. The end point it the crosshair hitbox + random number multiplier and the random sometimes makes the numbers too a shorter distance.

1 Like

Normalise the Make Vector in the 3rd pic and multiply it by a fixed (int or float) value, then add the other coordinate as you already do. You have the nodes sitting there already, it seems, twiddling their thumbs.


And here’s an alternative to making direction with some randomised offset:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.