Enable/Disable Physics in Blueprints
How do I enable/disable physics (or collision) for an actor in a blueprint?
For example, let's say I step into a box trigger. I want that to enable physics for an actor somewhere in the level.
asked Jul 27 '15 at 04:14 PM in Everything Else
You first need a stored reference to the actor you want to affect. That means, when it is spawned into the world, you save that instance into a variable located in a place/blueprint that is easily accessible. For example, if you simply place the actor into the level from the editor before the game is played, select the actor in the editor, open your level blueprint then right-click into the event graph and select the option near the top that says something like "Create a Reference to (you objects name)". This will drop a reference component into the graph for the actor.
Since the level is still pretty difficult to get access too from other blueprints, you need to store this reference to the actor somewhere else. Open your custom Game State blueprint and create a new variable with a recognizable/descriptive name to the actor you want to store and make sure the variable has the same Type as the actor (i.e. if your actor BP is called MyActor then make the variable type MyActor and choose the blue 'Reference'.)
Then, back in your Level BP, get the node 'Get Game State', drag off the output blue pin and do a "Cast To (your custom Game State name)". Hook the execution of the Level BP into the execution pin of the Cast To node. From the blue result pin of the Cast To node, choose "Set MyActor" ('MyActor' being the name of your custom variable for the aforementioned actor.) Then, hook the persistent actor reference (the one you created at the very beginning of this) into the Set pin.
Now, when you enter your trigger, or however you want to get access, simply do "Get Game State --> Cast To (custom Game State) --> Get MyActor --> Set Simulate Physics" and you're done! Well, almost... One caveat to this is you will most likely need the component of the blueprint you wish to set physics on, as physics can be ran independently per component on a single blueprint. When selecting the "Set Simulate Physics" from the step above, you will most likely have multiple options for each component of the blueprint so select the one you want. For example, if you are trying to set the Mesh of a Character type blueprint, select "Set Simulate Physics (Mesh)".
Hope this helps! If it does, please accept the answer by clicking the check mark next to the answer. You will know you got it right when the answer and all its comments turn green!
NOTE: Making a comment after accepting an answer will deselect the answer as accepted
answered Jan 21 '16 at 03:47 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here