Hi people,
I’m new to this forum so I hope I don’t create this post in the wrong place.
So I’ve been a gamedev since 2010 when I started with XNA, so I’m very familiar with gamedev theory, also I work as a developer (C# mostly), so the only thing that I new at is Unity.
Right now (just for practice purposes), I’m creating a Megaman engine, and since this is my third day and I tried everything (only in my free time which is 2 hours per day), I would like to ask for help.
I’m trying to have a player that have the exact behavior as Megaman (NES Series), but I’m facing with the issue that the player can’t stop moving inmediatly when I release the button (let’s say, RightArrow). I need the player to stop and don’t deacelerate, as it is doing right now. I believe this is normal because what I’m using is the following:
if (Input.GetKey(KeyCode.RightArrow))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}
And I’m setting moveSpeed to 5. So when I release RightArrow, it deacelerates, giving the player some kind of friction. I had no issue with XNA since I was dealing with X and Y positions, so no speed. Then in other platforms such as Construct, I just entered a high number in Friction property, and it worked as expected.
What’s the way to handle this?
Thanks a lot!