Make my Code DRY Challenge

Hi everyone,

Here is my attempt in making my code DRY. I made it so that the number of steps moved is set before starting the game in unity and I tried to use as little lines of actual code as possible. Hopefully it matches up with the solution!

Hi All,

I have a doubt in the code while writing a general function CheckForMovement, 2 arguments are passed to it : - (KeyCode kc, Vector2 movementVector). But upon developing this function the declaration for KeyCode kc and Vector2 movementVector is deleted. How do these variables work without a declaration like :
KeyCode kc = KeyCode.LeftArrow;
Vector2 movementVector = new Vector2(-1, 0);

Kindly assist.

Regards,
Srini

Privacy & Terms