Hey, so as I was coding and I realized that instinctively I add spaces in between my lines of code and was wondering if anyone else does or did the same format as I did and if there was a name for this type of thing.
Example:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
public float HitPoints = 100f;
public GameObject Zombie;
//create a public method which reduces hitpoints my method
public void TakeDamages(float Damage)
{
HitPoints -= Damage;
if (HitPoints <= 0)
{
Destroy(Zombie);
}
}
}
What you’re generally describing is known as Code Formatting, and it covers things like whether you indent with tabs or spaces, whether you put your opening curly braces on the same line as your ‘if’ statement or on the following line, and a bunch of other controversial topics that software engineers love to debate.
Note that most IDEs support autoformatting your code according to some basic rules, to keep the code consistently formatted even if multiple developers are working on it.
Yuck!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
public float HitPoints = 100f;
public GameObject Zombie;
//create a public method which reduces hitpoints my method
public void TakeDamages(float Damage)
{
HitPoints -= Damage;
if (HitPoints <= 0)
{
Destroy(Zombie);
}
}
}