Infinite loop detected. Not able to figure out why? (Uploaded ScreenShorts)

(BP_Equippable has child BluePrint BP_Weapon and BP_Weapon has BP_ToughSword and BP_GreatSword as its child BP. )

you are Destroying something that is being attached…

also I am unclear what your AttachActor Event is supposed to be doing is it trying to attach itself to itself, which yeah that would be an infinite recursion loop.

What I think is going on:

  • the Pawn interacts with one of these “Weapons”
  • the you see if there is currently a “weapon”
  • you equip the “Current Weapon”
    *attaching the “Current Weapon” to a socket somewhere (this might be attaching itself to itself :person_shrugging: )
  • Destroy the “Current Weapon”
  • finally Set the “Current Weapon” to the “New Weapon”

are you sure that is what you intend to have happen?

in my mind the OnEquipped should be called with the “New Weapon” not the Current one
you might still want to get rid of the “Current Weapon” if that is your intention

I have BP_Equippable which is parent of Bp_Weapon.

BP_Equippable Have OnEquipped , OnUnEquipped, AttachActor, SetIsEquipped and GetIs Equipped Functions.

BP_Weapon have overrided OnEquipped function.

And There are two child actor(Weapons) derived from BP_Weapon.

I want to remove weapon that i have, when i equippe another weapon
(sockets for both weapon are different)

the first fix is that your OnEquipped should have the New Weapon as the argument not the Current Weapon which should either come directly before or after the call to Set_CurrentWeapon()
then move the node down to the “Then 1” Exec line and attach your IsValid(CurrentWeapon) to your Destroy Actor (though this could/should be OnUnEquipped())
Maybe also putting an Is Valid (New Weapon) before you call the OnEquip with that

the error even says “Attempting to Access Actor* but Actor* is not valid (pending Kill or Garbage)” so you are trying to Attach a thing that is being Destroyed.

even though AttachActor doesn’t have a Clock (meaning Asynce or delayed) there is still a tiny delay for it, and so it is marked for Destroy, in the Middle of you trying to Attach it.

move the Node, swap the Argument and you should clear what the editor is calling a Logic error (a null access issue cased by race condition), and you will also remove what I can presume to be unintended behavior.

this is what I am suggesting:

There are no errors but now on pressing E key i am not equipping weapon

where in the chain does it fail?
debugging blue prints gets special, but there are tools to step through the chain to see what is failing where (just remember that the blueprint debugger can’t peek into C++)

Right click a node in the chain (probably start with the Sphere Trace) to add break point, and see what the result is then step through to see where it has something unexpected.

if the Input Action itself isn’t firing then check your Input Mapping Context to see if it is registered there (and for C++ that the Input Action is even assigned)