Question by
srajchevski · Nov 30, 2016 at 08:10 PM ·
c#2dcontrolsinputmanager
Changing (swapping) users movement controls IN GAME on trigger (2D)
I have an object, which when triggered has to swap the selected player's left and right controls. Here's the trigger function:
public class confuse_powerup : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.name == "player1")
{
// swap a,d controls
}
else if (other.gameObject.name == "player2")
{
// swap left,right controls
}
}
}
The controls are defined like this in the InputManager:
I tried swapping the keys' values like this, but it didn't work.
var left = Input.GetKey("a");
var right = Input.GetKey("d");
left = Input.GetKey("d");
right = Input.GetKey("a");
screenshot-54.png
(63.4 kB)
Comment