I have base class which contains a Vector2 velocity field, which I was initializing in the constructor with Vector2.Zero. But that caused an issue so I had to replace it with new Vector2(0, 0)
public abstract class BaseEntity { private Vector2 velocity; public BaseEntity() { // velocity = Vector2.Zero; // this causes the issue velocity = new Vector2(0, 0); // this I am using now } } The problem was that when I was adding other entities like Ship, Rock which extend the BaseEntity they were always moving in the same direction. So when I was moving the player, rocks and other entities which extend that BaseEntity class were following movement of my player.
I am not able to understand why that is; could someone explain to me why that issue occurred?