How to Swap Action Maps

Tyler Smallwood
2 min readApr 25, 2023

--

Objective: Talk about Swapping out Action Maps.

We currently are using only one Action Map. In a game there will be a chance to move from walking Action Map to a Driving Action Map. Today we will cover out to swap between the two. The first place to start is create a new Action Map.

Next will be to add an 2D Action for both Letters and Arrows. I created an ActionSwap action as well with the binding being T.

The next thing to do is go into the Player Action Map and create a ActionSwap action as well.

Now into the script we need to subscribe to SwapAction action and the Car’s ActionSwap.

In each method that was created we will need to enable and disable the correction Action Maps. In the Players SwapAction method we will Enable the Car Action Map and disable the Player Action Map.

Same goes for the Cars ActionSwap method.

Now to see if it works, we will need to set up the Movement actions.

Now when we play, Player Action Map is activated first. Under player action map, we can control the color and rotation. But as soon as T is hit, the cube starts to move.

That’s how we can easily transition between action maps. Thank you for reading and have a wonderful day.

--

--

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer