How to prevent line trace from attempting to access variable?

I’m not even entirely sure if this is the case but I think my line trace is attempting to access a variable or it is causing something for the variable to be accessed?

My aim is for the line trace simply hit an object, then for some relevant text to appear on screen for said object.

Here is my code for the line trace itself:

This then triggers an event within the game mode, which in turn triggers another event to occur within the user interface to change the PressKey variable from “test” to display “This works” on my user interface.

I’ve used settext (text) to alter the “Press Key” variable, which is some text on the user interface.

However when I go to test the game, the text does not change whatsoever, and instead I receive accessed none errors.

The reason I think it is because of the line trace, is that when I trigger the same piece of code by something anything other than the line trace (such as a simple F key press) it works just fine.

Try the ‘is valid’ and the print the other way around?

Thanks for the response! I haven’t tried this yet but I put the print string there just to confirm that the line trace was identifying the object, I think the issue was occurring before I put the print string there.

Do you think the IsValid is causing the issue though?

No, I think the print string is :slight_smile:

1 Like

I’ve just tried removing the print string and unfortunately the error still persists! Just to preface, this error only occurs when the line trace hits the object and begins executing the settext (text) code

Ah! - the none is coming from elsewhere then, I’m guessing…

Indeed! I’m just trying to understand how the line trace would be interfering with the “pressKey” variable. Since it is that variable that is coming up as the none accessed error, even though the variable has a value, which is the text.

I feel like the line trace is trying to access the “pressKey” variable as a value that isn’t what it is? Just a guess though

It can’t access it, because it returns an actor reference, which has no such variable.

You could post the actual error message - not only does it tell it what is wrong, precisely, but is also hyperlinked and, once clicked, will take you to the offending node. There is not enough script shown to determine what is going on.

1 Like

Apologies I tried to send the images in the original post but it didn’t allow me since I’m a new user ahah. But here’s the error message below!

image013

Here is also the script for the user interface, where the error message takes me

So, what is Press Key, really? Did you create a new variable without giving it value? Because that’s not going to work.


In the widget with the text block:

image

Ensure it’s ticked - it will expose this native element to scripting and allow you to set its data:

No need to create additional variables.

Sorry I really haven’t explained this very well :sweat_smile: I’m really a rookie in this, it’s my bad for doing such a bad job with this question!

The variable isn’t created out of nowhere however, it is a piece of text on the user interface that has been checked as “is variable” and given the name pressKey

Furthermore the script works exactly as intended when this whole series of events is triggered by something simple like a key press. But when it is triggered by the line trace, it comes up with this error

Could you show the rest of the script then, what does the line trace actually trigger?

So the line trace is effectively a crosshair for the player. When they look at an object, they will be able to interact with it.

This is what follows the line trace script:

1 Like

Which in turn triggers this

1 Like

Now that we see the entire picture, it all seems fine indeed. We’ll need to look at the stuff we cannot see here.


Could we see the widget hierarchy and the list of its variables?

1 Like

Of course! Here is the widget hierarchy. The only variable is “pressKey”

Can we see the details panel, like so: