Skip to main content
grammar
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

Libgdx Vector2.Zero unexpected behaviour when use forused to initialize Vector2

I have base class which containcontains a Vector2 velocity field, which I was initializing it in the constructor with Vector2.Zero. But that was mycaused an issue whichso I havehad to replace it with new Vector2(0, 0)

public abstract class BaseEntity { private Vector2 velocity; public BaseEntity() { // velocity = Vector2.Zero; // this is causes the issue velocity = new Vector2(0, 0); // this I am using now } } 

So theThe 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 waswere following movement of my player. 

I am not able to understand why is that, is; could someone smart in here explain to me why that issue occurred?

Libgdx Vector2.Zero unexpected behaviour when use for initialize Vector2

I have base class which contain Vector2 velocity field which I was initializing it in constructor with Vector2.Zero. But that was my issue which I have to replace with new Vector2(0, 0)

public abstract class BaseEntity { private Vector2 velocity; public BaseEntity() { // velocity = Vector2.Zero; // this is causes the issue velocity = new Vector2(0, 0); // this I am using now } } 

So 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 was following movement of my player. I am not able to understand why is that, could someone smart in here explain me that issue?

Vector2.Zero unexpected behaviour when used to initialize Vector2

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?

Source Link
noname
  • 103
  • 3

Libgdx Vector2.Zero unexpected behaviour when use for initialize Vector2

I have base class which contain Vector2 velocity field which I was initializing it in constructor with Vector2.Zero. But that was my issue which I have to replace with new Vector2(0, 0)

public abstract class BaseEntity { private Vector2 velocity; public BaseEntity() { // velocity = Vector2.Zero; // this is causes the issue velocity = new Vector2(0, 0); // this I am using now } } 

So 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 was following movement of my player. I am not able to understand why is that, could someone smart in here explain me that issue?