public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
public float forwardForce = 2000f;
public delegate void MovementFunction();
private Dictionary<KeyCode, MovementFunction> movementFunctions;
void Start()
{
movementFunctions = new Dictionary<KeyCode, MovementFunction>();
movementFunctions[KeyCode.A] = MoveLeft;
movementFunctions[KeyCode.D] = MoveRight;
}
void Update()
{
foreach (var keyFunctionPair in movementFunctions)
{
if (Input.GetKey(keyFunctionPair.Key))
{
keyFunctionPair.Value();
}
}
}
void MoveRight()
{
rb.AddForce(200,0,0);
}
void MoveLeft()
{
rb.AddForce(-200,0,0);
}
}
y'all think this is a good way to handle movement? I'm making a begginer cube evasion game from brackeys and i thought i would have fun with input, didn't like the multiple if statements on there
spoi0101 was banned.

No

