x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Custom Event doesn't react

Hi, I'm trying to make a CCrosshair "selection" and when I press one of my button for selection :alt text

A Custom Event Should Be called... alt text

alt text

But It does not work. When I clicked on the button it does not print the second string : alt text

If you can help me it would be really great ... Thank you !

Product Version: UE 4.21
Tags:
capture.png (37.1 kB)
capture1.png (71.7 kB)
capture2.png (158.9 kB)
capture3.png (5.1 kB)
more ▼

asked Jun 15 '19 at 10:53 AM in Blueprint Scripting

avatar image

Shawrex
1 1 3

avatar image Everynone Jun 15 '19 at 11:03 AM

How did you reference PlayerUI. Are you seeing anything in the log? Access None errors?

avatar image Shawrex Jun 15 '19 at 11:44 AM

I just created a variable refence to Player UI. Is it why it doesn't work ? What do you think I should do ? Thank's a lot !

avatar image vicecore Jun 15 '19 at 11:59 AM

Great News - Your custom event is working fine

See the picture:

Green = Good / Red = Bad / Yellow = Your Problem

I realized this when you said " it does not print the SECOND string..." - Best of Luck

alt text

279874-capture2.png (144.8 kB)
avatar image Shawrex Jun 15 '19 at 12:17 PM

Sorry. When I was saying second print. It was before I remove the print So what there is 3 prints There was the first : Saying if i called the event The second : Saying if the event has received the call And the third : Saying the new value for the crosshair

avatar image Shawrex Jun 15 '19 at 12:24 PM

But thank you i'll correct that !

avatar image vicecore Jun 15 '19 at 12:38 PM

happy to help

avatar image Shawrex Jun 15 '19 at 01:34 PM

Okay, Thank's to you guys. I solved the first problem. But here is the thing. Now I can't even Modify my in-game crosshair The modifying of the value of "Crosshair" works. But the Get_Text to update the crosshair does not work anymore : Here is it. alt text

I don't know why and I think you can't help me with this. So if you need something, tell me.

capture.png (78.6 kB)
avatar image Shawrex Jun 15 '19 at 03:41 PM

The crash probabl come from one of the blueprints cuz' there are two options : Or the UI doesn't appear Or it appear but not with the good Crosshair ...

avatar image SithHunter Jun 15 '19 at 03:48 PM

At what point is this function run? If it comes before the Set Crosshair node then it won't have anything in it unless you have a default value.

avatar image Shawrex Jun 15 '19 at 11:10 PM

What did you mean about the function Run ? Can you explain. I'm new, it's my first project. (From Blank)

avatar image vicecore Jun 16 '19 at 07:20 AM

I think I understand what's happening here, but it's going to require some elaboration on my part - so stick with me on this

What Sithunter is asking is this...

We can see that you have created a function called "Get Text_0". He's asking WHEN is that function being called?

Because - if it's called BEFORE Set "crosshair" occurs (which happens when you call the Custom Events in your picture that I sent back to you yesterday), then it won't have the information from that corresponding setter.

Now - all that being said (and correct me if I'm wrong) from my experience I believe that specific function "Get Text_0" was created from a "Binding" in the widget BP your working in

If I'm correct with that, then you have to understand that binding function - is running constantly. It's not like a regular function that you would call manually. And to Sithunter's point, its running BEFORE your custom events are called to Set "Crosshair"

So before going any further, I want to just confirm that you understand everything I'm saying here so far? If so, then I will continue with potential solutions for your problem

avatar image Shawrex Jun 16 '19 at 09:30 AM

Okay, I knew about the binding text function who run constantly. But the problem is "why it doesn't run ?" So I don't know why I should call this function ? If it run constantly

I'm now okay with what your saying. Thank you solving my problems. You can continue

avatar image Shawrex Jun 16 '19 at 09:34 AM

I tried some things.

When I don't put anything on the textbox : Nothing changes.

When I try to put a value to my "Crosshair" variable (text) : The new value is on the screen.

  • Now we now that we have a problem with the "Crosshair" var.

  • The Player UI is well-displayed.

I don't know at all what's going on with my blueprints ...

avatar image vicecore Jun 16 '19 at 11:11 AM

ok lets back trace just a moment here

you asked: "why it doesn't run ?" - I'm saying it does run, its just that the variable in it "crosshair" has no value initially

you asked: "So I don't know why I should call this function? If it run constantly" - I'm saying you don't have to call this function at all, we're in agreement it's being called constantly

In regard to the "Crosshair" variable: On Event Begin Play / Event Construct (for the widget) - "GetText_0" is running

But the value of "Crosshair" isn't set at that time - why - because it's not set until you call the custom events that set them (as per your picture)

Now moving forward, I want you to simply test the binding by setting the print string node to say "hello", as shown in the picture

Then when you PRESS PLAY - confirm that print string is firing off

If it fires - we're in good shape and we can continue...

If it doesn't fire - let me know and we'll continue to trouble shoot

alt text

screenshot-931.png (191.2 kB)
avatar image Shawrex Jun 16 '19 at 12:26 PM

When you say "fire", you mean spam. Because it's like spamming*10^30

I've already tried this it was the same.

For you, the problem is WHEN I set the value. But when you put a default value... (said before)?

avatar image Shawrex Jun 16 '19 at 10:08 PM

Yuping this post

avatar image vicecore Jun 17 '19 at 01:00 AM

Yes, print string should be spamming - excellent - that means the widget has been successfully created at run time and the binding function is working as expected

With that now confirmed - delete the print string - and connect the "crosshair" variable to the input of the return node

Now - don't expect to see anything appear just yet, because your "crosshair" variable contains no information (unless it has a default value)

From there - you need to call the custom event that sets the "crosshair" variable. Not sure exactly where or how your doing this, but when its called and sets crosshair, at that point it should appear on screen as a text.

That said, what BP are you calling the custom events from? Also, when are they being called?

avatar image Shawrex Jun 17 '19 at 03:47 PM

Sorry if I'm late. I was calling the "Custom Events" from my "OptionMenu". They are called when you press one of the buttons. So I think I need to wait before calling them, and call them when Player_UI is added to the player's screen ... It is right ?

avatar image Shawrex Jun 22 '19 at 12:55 PM

Uping this question, cause I need help please...

avatar image Shawrex Jun 29 '19 at 03:18 PM

Uping This !

avatar image DonBusso Jun 29 '19 at 03:35 PM

Hey Shawrex, I'm having hard time understanding what is going on here, would you dumb it down for me please? (it's really hot over here, hard to concentrate) :) Alternatively catch me on discord and maybe we can work it out together :) https://discord.gg/2hyyydR

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey all, posting this just in case someone else might need it, although this is a very "dirty" way of doing it. I'm sure there are better ways of doing it. At least it might give someone a head start and something to improve on.

So I've created two widgets, each with an image that represents the crosshair. I guess you could do with one and then just change the image itself. Image was anchored to middle of the screen with 0.5 alignment for x/y. Then I used similar widget as @Shawrex (see first screen on top of the post) with two buttons just so I could toggle between the crosshair types.

And below is the actual code (inside menu widget). I didn't play with it too much as it's a bit late here so some of the stuff might not be needed, but I will leave it to the professionals to point that out. Both widgets(crosshairs) are created when the menu widget is first created, then I just hid them and used buttons to toggle their visibility. As I said earlier this is a dirty way of doing it but it does work. We can't all be pros, can we? :)

alt text

verydirtyscript.png (321.9 kB)
more ▼

answered Jun 30 '19 at 01:16 AM

avatar image

DonBusso
805 4 5 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question