How to attach and detach objects from a player
Create a dynamic object which attaches and detaches to make your game more interesting.
In a delivery game scenario, where you need to collect and move a box to a specific location to score, here’s the easiest way to attach and detach an object from a player:
Select your object
The basics for all behaviors
The basics for all behaviors
- Tap on the object to which you want to add a behavior
- With the object selected, tap on the “Details” button to the left of your screen.
- In the Details panel, tap “Add Behavior”.
Set your Trigger
To attach the object when the player interacts with it, select the “Interaction” block and drag it into the behavior editor.
Set Object Action
In the “Object Action” section, drag the “Attach to Player” block below the trigger. Toggle the block and untick “Wait for completion”. Positive Y puts things above the player, positive Z in front of the player.
Create a Delivery Event
In the “Trigger” tab, choose the “With Player” Event Block and drag it into your canvas. Let’s add an effect when the box is delivered. In “Effects”, select “Add a Particle Effect”. Toggle the block and choose the desired effect. Then, let’s cancel the movement of the block being attached to the player. Choose the block “Cancel Animation”. This will detach the object from the player upon delivery.
Behavior Image
Behavior Image
Create a Delivery Area
Choose an object where the object will be detached. Tap on the “Details” button.
Trigger for the Delivery Area
Choose the “Player Touches Object” Trigger block to trigger the action when the player reaches the delivery spot. In the “Miscellaneous” category, pick the “Plain Event” block. Toggle it and name it “Deliver” to match the variable created.
Behavior Image
Behavior Image
Playtest!
After setting up the movements, test your game to see how the object behaves and make adjustments for the perfect effect.