Can't use collision box reference passed into a function

UE 4.10.4

I have a character class that has collision boxes/capsules parented to the capsule component.
(They were added as components via the Component Add window on the left.)

While the game is running, each box has a begin overlap set up in the character’s event graph where it checks to see what entered and decrements a variable for damage if it matches the criteria (component tag). When that damage var reaches a certain threshold I want to destroy/disable the collision.

The only way I could find how to do seems really sick (there are 14 collision boxes/capsules).
The way I do it now is pass the name of the collision box or capsule to a switch and then call a separate destroy component (or set collision enabled ) for each one.

I can pass the collision reference into a function as an actor component, but it doesn’t seem I can do anything with it after that, i.e. that reference isn’t compatible with Destroy Component or Set Collision Enabled within the function. That is why I’m doing it sick way.

Thanks!

Hello ,

Could you show some blueprints to give us an idea of your set up here? Depending on where you’re setting variable for the damage and where you’re checking to see if it has reached the threshold, you should just be able to disable collision for that particular instance without needing a switch statement. I would need to see your structuring to understand how to set that up however.

Hello ,
Thanks a lot for the response. I apologize for my late one.
Here are the relevant pics listed in order of execution.

(Warning: Lots of bland spaghetti incoming)

Damage variable is set here. (I realize it’s bad to hard code .)

Threshold check and disable collision function called if passed here

Collision disabled here

Are the individual parts responding to collision? What is your intention with these individual parts? Are they meant to be detached separately, such as the arm falling off if the weapon hits that arm? In most cases, the editor is only going to take the root component’s collision into account so I’m interested to know if the collision is working for each one of these components.

Hello, . Thanks for the prompt followup.

Yes, as far as I know collision is working correctly. However, the only collision I check for is if its a weapon. Everything else is ignored. The collision and body parts all have the same priority in the hierarchy of the character class, and each collision box is attached to its own socket in the main, inherited mesh (the torso with the skeleton).

My intention with these parts is that once they receive enough damage, I want to completely get rid of them. I destroy it and create a static/destructible mesh in its place (that’s not tied to a skeleton with animation) with simulate physics enabled so I can kick it around and stuff.

Yes, they are meant to be detached separately, but only if it’s an extremity (hand, foot or head). If the upper arm or leg takes enough damage everything connected to it falls off (i.e., if upper leg then, if valid, lowerleg+foot or if upperarm then lowerarm+hand).

The collision is working for each of these components. But, seeing that I have no use for them anymore, I thought I should destroy’em to free up resources.

I have the system working correctly, but it’s a bunch of copy-pasted nodes.

Is there some info I can read up on regarding how component, mesh, actor references work as inputs for functions?

Thank you!

Are all of these components (Foot L Hit, Foot R Hit, and so on) all the same type of component? If so, is there a reason you cannot use the My Component output from Check Weapon to go into Analyze Part with (and the same with Disable Collision)? You could ignore the part name input (or keep it if you need that) and add an input for that type of component.

It could also be helpful if you made a custom component that contained both the Skeletal Mesh for a body part as well as the Collision component so that could be passed in and the individual Mesh or Collision components could be referenced off of that.

Hey!
Aside from the Head_Hit, which is a capsule component, they are all the same type (Box Collision). My initial problem with though was that even once I passed either of the collision references into the function they wouldn’t get recognized by the method (set Enable Collision, or Destroy Component) within the function (the crossed out circle showed up when trying to connect it).

I tried it again just recently and it was recognized, but I’m pretty darn certain I did the same exact thing as before.

Aside from completely failing numerous times in a row, there are 2 other reasons I can think of:

  • When I initially ran into the problem, UE4 was open for a while so it was a little sluggish
  • I’m running UE4 on a Japanese Windows 7. Some nodes don’t appear unless I search for them in Japanese to get methods/functions to appear. Maybe somehow node/function lookup table got corrupted or something because unicode characters were used, and that also messed up the types the inputs on the nodes were expecting…

“It could also be helpful if you made a custom component that contained both the Skeletal Mesh for a body part as well as the Collision component…”

Cool! I’ve never made a custom component before. I’ll give a try in an effort to consolidate the character class components. I’m sure I can find some examples of how to extract individual components from custom components passed into a function.

I’d say issue is fixed mainly on account that I learned some new stuff thanks to you.

I’m not exactly sure the cause of the components failing to get recognized though.
(I know for a fact I passed the “Box Collision” component into a “Box Collision > Reference” (and “Capsule Collision Component” into a “Capsule Collision Component > Reference”) input on the func successfully. That sucker must’ve come out as a “brundle” collision within the function, because it just wouldn’t get recognized by the disable/destroy).

Are all of these components (Foot L Hit, Foot R Hit, and so on) all the same type of component? If so, is there a reason you cannot use the My Component output from Check Weapon to go into Analyze Part with (and the same with Disable Collision)? You could ignore the part name input (or keep it if you need that) and add an input for that type of component.

It could also be helpful if you made a custom component that contained both the Skeletal Mesh for a body part as well as the Collision component so that could be passed in and the individual Mesh or Collision components could be referenced off of that.

(Had to readd , as the previous post disappeared when I converted it to an answer.)