I'm trying to make a game in the style of many NES games and I'd like object movement to do two things:
I want to move an exact number of pixels per update.
I want, for lack of a better term, absolute movement. The object should move or not move, I don't want a ramp up or down in speed.
I'm trying to do this with physics because I would like to use Unity's hitbox collision detection. Moving objects using the translation property does not allow for this, at least that is my understanding.
Any help is appreciated and if my thought process is off, I'd like any suggestions or pointers in the right direction, thanks.
Here is my move method that gets called on Update. I expect to movement to be in whole pixels, however, when I test the x and y are always fractional.
private void Move()
{
VerticalMovement = 0;
HorizontalMovement = 0;
if (Input.GetKey(KeyCode.W))
VerticalMovement = 1;
if (Input.GetKey(KeyCode.S))
VerticalMovement = -1;
if (Input.GetKey(KeyCode.A))
HorizontalMovement = -1;
if (Input.GetKey(KeyCode.D))
HorizontalMovement = 1;
this.GetComponent<Rigidbody2D>().velocity = new Vector2(HorizontalMovement * Speed, VerticalMovement * Speed);
}