Attaching/Detaching component

I am pretty new to UE and am not the best at blueprints. Essentially my goal is to grab an object infront of me. I can successfully grab an item that is grabbable and hit by the sphere trace, but after dropping, every subsequent grab input will attach the dropped item to the character regardless of if it is in range. My understanding is that the HitbyGrab variable isnt clearing but I am unsure how to go about clearing it as every time I try to set it there are no changes. I know this is probably extremely simple but any help is appreciated.

1 Like

Hm, you even clear it twice. The script seems fine at a glance.

Could we see the trace? And could we see an example of a grabbed actor’s (the one with the interface) component hierarchy. What I am hinting at here:

  • if you have an actor with a physics simulating component that is not at the root:

  • and go ahead and simulate it:

The mesh will fall, sure; however, the actor location will not change - see the gizmo above. If you then trace and manage to hit another component this actor may have, the trace will not fail even though this one static mesh that has fallen is now beyond the trace’s reach. You may simply be hitting the actor and fetching its component from wherever it rests.

There are a couple of ways to work around it:

  • ensure the actors have only one component
  • or ensure the simulating part is at the root of the actor
  • or work with Hit Components instead of Hit Actors:

Admittedly, it’s a bit of guessing game without more details even though you’ve provided plenty, and a clean setup to boot.

3 Likes

I cannot attach images outside of a post apparently, but thank you for your help. Turns out it was completely simple (I think), but after messing with some things I fixed it by attaching a branch after the trace function that on trace return true then checks if implements interface and so on. Not entirely sure why this fixed it as the trace function itself has a branch before return node that to my knowledge serves the same purpose. Thank you for responding, probably wouldn’t have solved this without you .

Traces

  • I removed the loop from this new trace function as it was pointless.

New Grab Script

  • added branch after “Grab Line Trace”
1 Like

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