Swapping Characters during Gameplay in Unity Playground

Опубликовано: 15 Апрель 2026
на канале: ProfMoto
186
5

What if you want your walking character to turn into a flying character? You can't just swap the graphic, you also need to completely change the movement for the character. This tutorial shows you how to make this happy quickly and easily in your Unity Playground game.

If you want to try this experience out before doing the tutorial:
https://play.unity.com/p/webgl-builds...

Commands used in this Tutorial:
File- New Scene
Right Click in Hierarchy and create new 2D Object- Tilemap- Rectangular
Create a ground with one of the tiles.
Tag this tilemap Ground
Create a new character on Kenney.nl
Set this up as a multiple sprite and slice it
Drag this character into the Scene and create a new animation
Name this character (blueCharacter for my tutorial)
Set this character’s location to 0,0
Add a PolyCollider2D
Add Move with Arrows
Set Move with Arrows to WASD
Set Move to Only Horizontal
Set move to Orient to Direction (right)
Add Jump
Make this character a prefab

Create a new character on Kenney.nl or download the Tappy Plane Asset Set
Set this up as a multiple sprite and slice it
Drag this character into the Scene and create a new animation
Name this character (redPlane for my tutorial)
Set this character’s location to 0,0 (hide the other character temporarily if necessary)
Add a PolyCollider2D
Add Move with Arrows
Set Move with Arrows to WASD
Set Move to Only Horizontal
Set move to Orient to Direction (right)
Add another Move with Arrows
Set this one to WASD
Set this Move’s speed to 2
Set this Move to Only Vertical
Make this character a Prefab
Delete it from the scene
(Unhide the original character if it was necessary to hide it)

Select the first character (blueCharacter) in the Assets
Add Condition Key Press
Change Key to Press to E
Add Create Object Action on the Condition
Create Destroy Action on the Condition
On Create Object set the Prefab to Create to the second char (redPlane)
Set the New Position to 0,0, or for a plane, 0,1 is a better idea
Set this Relative To This Object
On Destroy Action set the Target to This Object
Save this prefab if prompted

Select the second character (redPlane) in the Assets
Add Condition Key Press
Change Key to Press to E
Add Create Objection Action on the Condition
Create Destroy Action on the Condition
On Create Object set the Prefab to Create to the second char (redPlane)
Set the New Position to 0,0
Set this Relative To This Object
On Destroy Action set the Target to This Object
Save this prefab if prompted

Playtest
https://play.unity.com/p/webgl-builds...