Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: FrozenKing on June 20, 2023, 08:40:55 AM

Title: How to Grab an Object
Post by: FrozenKing on June 20, 2023, 08:40:55 AM
Hello, this is my first post here  :)
I followed this tutorial, but it seems I could not grasp it properly  1)What components (box collider, rigid body, etc.) should the object I want to grab have?
2) For example I try do grab a cube, which has a box collider and a rigid body components, with no FSM or actions to IT,
 so in the FSM view(player's), it shows that action goes to GRABBABLE CHECK, but then returns to the first state.

How should I make this work? Here are the screenshots of my states, actions and variables, can anyone help?
(https://i.ibb.co/7SH2LVV/7.png) (https://ibb.co/0nkhvZZ)
(https://i.ibb.co/0Gp7tnS/6.png) (https://ibb.co/QK7gdJR)
(https://i.ibb.co/sK66nbL/5.png) (https://ibb.co/VgQQRJX)
(https://i.ibb.co/d0vxRgB/4.png) (https://ibb.co/jvYsSRh)
(https://i.ibb.co/PMTfm1t/3.png) (https://ibb.co/8bzSKPX)
(https://i.ibb.co/S0ctqvV/2.png) (https://ibb.co/sQCKL3s)
(https://i.ibb.co/WgQJG7g/1.png) (https://ibb.co/Hn08BRn)
Title: Re: How to Grab an Object
Post by: djaydino on June 20, 2023, 06:20:39 PM
Hi.
in the tutorial the target box should have an fsm with a bool isGrabbable.

but instead you can set a tag on the object and do a Game Object Compare Tag.
this way the target object does not need an fsm

You can also try without a grabbable check.
Title: Re: How to Grab an Object
Post by: FrozenKing on June 21, 2023, 07:04:10 AM
Thanks for responding

I tried executing the action without the GRABBABLE CHECK state and it worked indeed, I could grab an object and throw it as well. but the issue was that I could grab anything in the scene (ground and every mesh), is it possible to fix this?


One thing I noticed: as you mentioned, on the GRABBABLE CHECK state, I had a wrong spelling of a variable, instead of "isGrabbable" variable I had a "IS GRABBABLE" , it s shown on my second screenshot, but the thing is, when I create the new variable named "isGrabbable", and try to enter the same name in the Store Value field, it says that "Name Already Exists".

Can you elaborate on the third option of setting a "Game Object Compare Tag" ? I'm a complete newbie with Unity and Playmaker.
Title: Re: How to Grab an Object
Post by: djaydino on June 21, 2023, 07:15:41 AM
in editor mode,
Select the target object, then in the inspector near the top you will see Tag and Layer

Click on the tag dropdown and select add tag, this will open the tag manager.
Then create a name (for example "Grabbable /Throwable")
after creating the tag, set it to the objects that will be throwable.

then on the 'Grabbable check' state, remove the actions and place the action :
"Game Object Compare Tag" and compare it to the tag you created.

later if you want to have grabbable but not throwable you can make different tags and use "Game Object Tag Switch" instead of compare.
(for example a heavy object that you could push/pull)

Title: Re: How to Grab an Object
Post by: FrozenKing on June 22, 2023, 07:51:26 AM
Thanks for responding, I turned it into a satisfying state.
I have one question though, if you can help, whenever I import a custom object in Unity and then create an fsm on that object, it says this:
(https://i.ibb.co/s1ynHSC/1.png) (https://ibb.co/SmRbrTc)

And when I press apply, it says the following:
(https://i.ibb.co/vV86rgR/2.png) (https://ibb.co/gmCLXHh)
Title: Re: How to Grab an Object
Post by: djaydino on June 22, 2023, 11:42:29 AM
Hi.
I not sure why, if you open the prefab and add the fsm there?
Title: Re: How to Grab an Object
Post by: FrozenKing on June 23, 2023, 10:12:47 AM
Kind of found the solution

I selected the model in hierarchy, right click on it, Prefab>Unpack Completely
After that I was able to add fsm on it without any issue.