How to display a variable value from object you look at ?


I want to be able to get variable value from an actor that my character look at. Currently im making a game where player is equipped with a scanner and when player look at bunch of different actor/bp the scanner show some information about the actor/bp. All of the actor/bp contain same variable name and type. Another Example

Do you mean

  1. How to get the info?

  2. How to display it on the screen?

1a) Make all the blueprints inherit from the same class, then you can just query the variable.

1b) Use a blueprint interface. Then you can query any actor.

  1. Print string or Widget :slight_smile:
1 Like

Im sorry im very new, but i dont see how can i get a variable value from random actor that have the the same variable. Its like trying to take a variable using casting mode but the class is what u touch

When you say ‘touch’ you mean overlap, right?

Then you have the other actor

image

That’s a reference to the thing you just touched.

You can cast it to your blueprint, or send it a message on an interface.

then how do i get a specific variable from it?

In other word how do i get a variable from a object reference i get after game start

This show you already know the blueprint name, let say, you dont know, but you do know it contain “My Variable”, now how do you take it. mmm .

In star citizen you can scan a rock and see its resources in it. Im pretty sure the resources value is in the rock bp. But idk.

Btw thanks for the help.

That’s what interfaces are for. You can get the variable from any blueprint without casting…

Also, depending on how you do it, they don’t have to be blueprints. You could just use static meshes with actor tags.

mmm, I`ll try to learn from this interface you talking about, anything specific should i look for ?

For now i solve my problem by make a tree of casting to all bp and grab variable from there.
In here raycast hit target > target become reference > if reference equal to cast bp that is called manually , take var from it

This is why the interface is better, you don’t have to do a different cast for each kind of thing…

Yes you are right, im having problem implementing this interface becoz its not firing


2

Player press button, fire function, Cube suppose to print, Cube is just a bp with static mesh that is inside the world, but only get Scanning printed
UPDATE: I find the problem, the Target | self | must refer to something, but that thing cant accept any obj reference saying its not compatible

I got it working, turn out im suppose to call the function in (message) not call function

Here player is looking raycast at object > actor ref > go to target in function > Other bp . Call the function event


2

1 Like