Skip to content
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

Merged
merged 1 commit into from
Mar 13, 2021

Conversation

abc013
Copy link
Collaborator

@abc013 abc013 commented Jan 3, 2021

Also a bit of cleanup.

My following PRs will depend on this one.

@abc013 abc013 added PR: Is Dependency Is dependency for other PRs PR: Ready for Review labels Jan 3, 2021
Comment on lines -11 to +15
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; }
Copy link
Owner

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

Comment on lines -78 to +69
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; }
Copy link
Owner

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

Copy link
Collaborator Author

@abc013 abc013 Mar 14, 2021

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);
Copy link
Owner

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);
Copy link
Owner

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

Comment on lines +33 to +47
// 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;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not in constructor?

Copy link
Collaborator Author

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.

@Wolkenfarmer Wolkenfarmer merged commit 1bd7f67 into Wolkenfarmer:main Mar 13, 2021
@abc013 abc013 deleted the paused branch March 14, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants