-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix variable speeds when having different FPS #20
Conversation
public float Speed; | ||
public int Health { get; private set; } | ||
public int Shield { get; private set; } | ||
public int Damage { get; private set; } | ||
|
||
int pHealth; | ||
int pShield; | ||
int pDamage; | ||
|
||
public int Health | ||
{ | ||
get { return pHealth; } | ||
} | ||
public int Shield | ||
{ | ||
get { return pShield; } | ||
} | ||
public int Damage | ||
{ | ||
get { return pDamage; } | ||
} | ||
public float Speed { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change, much simple
superb
public void setShield(int newShield) { pShield = newShield; } | ||
public void setHealth(int newHealth) { pHealth = newHealth; } | ||
public void setDamage(int newDamage) { pDamage = newDamage; } | ||
public void setShield(int newShield) { Shield = newShield; } | ||
public void setHealth(int newHealth) { Health = newHealth; } | ||
public void setDamage(int newDamage) { Damage = newDamage; } | ||
|
||
public void setSpeed(float newSpeed) { Speed = newSpeed; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, now I actually understand what's going on here.
This pHealth etc was sus to me anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very honestly wondering why I didn't remove those functions - you can set the variables by assigning them directly...
Woops, i missed the private
modifier.
@@ -39,7 +26,7 @@ protected virtual void Update() | |||
|
|||
public void Move(float h, float v) | |||
{ | |||
gameObject.transform.position += new Vector3(h * Speed, v * Speed); | |||
gameObject.transform.position += new Vector3(h * Speed * Time.deltaTime, v * Speed * Time.deltaTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course 🤦
Easy but important addition, very good!
setHealth(2000); | ||
setDamage(150); | ||
setSpeed(20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More individual, much good
superb
// Objects have to be initialized first so we can get their speed | ||
if (firstTick) | ||
{ | ||
foreach (var obj in objects) | ||
{ | ||
obj.transform.parent = group.transform; | ||
var enemyScript = obj.GetComponent<Enemyship>(); | ||
enemyScript.SetPartOfUnit(this); | ||
|
||
if (enemyScript.Speed < speed) | ||
speed = enemyScript.Speed; | ||
} | ||
firstTick = false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not in constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the components may have not been initialized yet, at least that's the reason I remember.
Also a bit of cleanup.
My following PRs will depend on this one.