playMaker

Author Topic: Pickup a rigidbody object and drop it  (Read 770 times)

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Pickup a rigidbody object and drop it
« on: November 26, 2020, 02:40:00 PM »
Hey there,

Trying to press a key when a character is close to an object and pick it up, when  you press the key again it drops it. I have most of the logic working, just not sure if I should be using Set Parent or some other action?

If I use Set Parent, what attributes do I need on the object you pick up? Do I need to disable rigidbody?

thanks!

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Pickup a rigidbody object and drop it
« Reply #1 on: November 26, 2020, 03:34:35 PM »
Using set parent should work fine.

On the object to pickup you could store all of the logic inside. For example have a Trigger event action (remember to set trigger in the inspector as well), and you can tag for example the player (or whatever the trigger is).

Then in the next state you can have your Set Parent action and set whatever object you would like to parent to (for example en empty game object that is a child of the main object), Also could have a Get Key Down action (space bar for example when pressed change the state.

In the last state use Set Parent again but this time set the parent object to "None" this will un-parent the object (and the object is dropped)

Hope it helps ;)

Edit: If you are using gravity you can turn that off and on by dragging the Rigidbody from the inspector into the State then do a set property to turn it on or off.
« Last Edit: November 26, 2020, 04:05:52 PM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: Pickup a rigidbody object and drop it
« Reply #2 on: November 30, 2020, 11:14:28 AM »
Great thanks!