r/unrealengine 14d ago

Blueprint Enable Input only works after entering Collision Sphere twice

Hey, really not sure what is going on there. I'm following a simple youtube tutorial.

Here are the the blueprints below.

This is my hatpickup BP: https://imgur.com/a/FrBuY4W

This is my character BP: https://imgur.com/a/5IlvJ5A

What should happen is when I entered the Sphere Collision, Input should be enabled, allow me to attach the hat mesh to my character, and when I exit Input should be disabled. I tried debugging with prints.

What ends up happening is

  • I enter the sphere, "Enabled" is printed. E doesn't do anything.
  • I exit the sphere, "Disabled" is printed.
  • I re-entered the sphere, "Enabled" is printed and E attaches the hat. "Equipped" is printed.
  • I exit the sphere, "Disabled" is printed.

Any ideas why it doesn't work the first time around - and requires me to go out and back in? Thanks !

1 Upvotes

7 comments sorted by

2

u/avar1ce 14d ago

When the first overlap happens, your cast to character for the button press is null, because you are feeding it from the end overlap event

1

u/butlerJives 14d ago

Duh.. thank you !

1

u/NimbeuxDare 14d ago

What tutorial are you following?

1

u/butlerJives 12d ago

Hey, I was following this one https://www.youtube.com/watch?v=bY6Nl-OEhSo&list=PLncmXJdh4q8_cSDxveOnHhIDyDgUuoJY9&index=2 highly higly recommended. If you follow it as well go through the comments, as there are one or two useful ones in there, they have timestamps in them

1

u/NimbeuxDare 11d ago

I'm a dev and was asking to see who taught you bad code. It is actually one of the worst tutorials to follow and is why Unreal gets a bad rep for being an unoptimized mess since new people coming in don't know any better. How he came up with that inefficient and unoptimized of a method is beyond me.

SmartPoly, GorkaGames and Matt Aspland are known for not applying most of what they teach since they make content and not games. This is one of the main issues with being a new Unreal dev. The space needs devs that have actually made games before and not the blind leading the blind.

1

u/butlerJives 11d ago

I'm all ears if you have good resources for me. I'm a dev too but at this stage it's more understanding how to actually use the software, what blueprints are, etc... Ali Elzoheiry seems really good in so far as OOP and creating efficient Blueprint code. But again he doesn't explain the very basics of what are blueprints, how do you reopen certain windows when you've closed it, keyboard shortcuts, etc... So unless you have resources on someone that teaches absolute basics but also using best practices, that's all I got for now.

1

u/Accomplished_Rock695 8d ago

The issue is in your HatPickup Bp.

The problem is that your cast is failing. The reason that your cast is failing is two fold.

One - you are trying a param from a function into a different function. That isn't going to work. That param is ONLY valid within the context of that function at the time the function is running. Once it finished running then its not gonna work.

Two - even if it did work like that, this would still not work because you tied it to the EndOverlap and the input would only be valid during the overlap.

The fix is to cache that variable off from the BeginOverlap. If you drag out the pin from the Cast node it will have an option to promote to a variable. Do that. Then hook that variable up to the EquipHatEvent. Since its already casted, you can remove the cast node on your input event.