Hello there. I’m still (very) new to UE and I’ve been struggling with this for a while.
I currently have a player who can pick up a chest, run with it etc, then drop it. Like this:
I have a placeholder “ItemDrop”, when the you click the E key, it sets the box blueprint location to the location of this “ItemDrop” placeholder. This works fine.
I want to be able to apply physics to the static mesh inside that blue print when I place the item back down, so it falls to the ground, but I can’t seem to figure out how to do this! I can’t seem to reference the static mesh inside the item’s blueprint, no matter how much I try.
Hey there @crEA-tEch! You’re doing great so far! So accessing the SM below the other actor’s hierarchy can be done a myriad of ways, but one of the better design patterns would be using Blueprint interfaces to tell any object you drop to run their own Drop logic instead of making the player BP try and look through the chest BPs children, finding the SM then setting it’s physics (which by the way will cause you issues in the future but I’ll address that after I address your actual question).
Basically blueprint interfaces is a good way to have a generic command that certain other objects all understand. For example, if you have a Use command, you’d want it to react differently for each object right? A light would turn on or off, a door would open or close, a chest would open close, etc. And all you’d need in your character BP is a reference and to call the use interface on them! It’s basically just a powerful way to consolidate actor communication however if you’d rather I can also show you the direct communication method. Here’s a tutorial on BPI’s and the documentation, don’t hesitate to ask any questions during implementation!
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
On to the future issue you’ll have. It looks like your chest SM component is actually a child of the root. For anything you make physically simulated you must have the mesh as the root of the actor. This is because whenever you enable physics on the chest itself it will immediately remove it’s parent and become it’s own actor. One that doesn’t retain any of the scripting you’d put in it’s event graph. Then because the parent is just a root it breaks it’s logic at best and at worst it gets garbage collected.
To do that just drag your chest SM component above the root in it’s hierarchy and you’re golden!
Thank you SO much for the detailed reply! That makes a lot of sense for more efficient blueprinting as I go forward. I will try this when I’m back at my desktop and let you know how I get on