Odin
Explore posts from servers❔ Is there a way to quickly change all instances of "var" in my code to "Country"?
I had ChatGPT do some stuff and it named everything var and I have a Country method, I need to convert every instance of var to Country over, let me check, 3500 lines of code.
//bad code
var Xape = new Country {
Name = "Xape",
ArmySize = 1831,
MaxArmySize = 2266,
Industry = 145,
MaxIndustry = 951,
Manpower = 633,
MaxManpower = 5397,
TotalTerritory = 41,
AvailableTerritory = 6,
Territories = new List<Territory> {
new Territory { Name = "Xapia", IsOccupied = False },
new Territory { Name = "Xapan", IsOccupied = False },
}
};
//good code
Country Dudu = new Country {
Name = "Dudu",
ArmySize = 1617,
MaxArmySize = 2002,
Industry = 404,
MaxIndustry = 800,
Manpower = 836,
MaxManpower = 7878,
TotalTerritory = 36,
AvailableTerritory = 34,
Territories = new List<Territory> {
new Territory { Name = "Dudor", IsOccupied = False },
new Territory { Name = "Dudis", IsOccupied = False },
new Territory { Name = "Dudia", IsOccupied = False },
}
};
5 replies
❔ GetAxis wont work
public class Driver : MonoBehaviour
{
// Start is called before the first frame update
const float MoveUnitsPerSecond = 5;
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
// Update is called once per frame void Update() { //move game object as needed Vector3 position = transform.position; if (horizontalInput != 0) {
position.x += horizontalInput * MoveUnitsPerSecond * Time.deltaTime;
} if (verticalInput != 0) {
position.x += verticalInput * MoveUnitsPerSecond * Time.deltaTime; } transform.position = position;
} } Why wont GetAxis work, the course i am going off of has this exact code but unity is saying that I cannot call GetAxis("Horizontal") from a monobehavior constructor
// Update is called once per frame void Update() { //move game object as needed Vector3 position = transform.position; if (horizontalInput != 0) {
position.x += horizontalInput * MoveUnitsPerSecond * Time.deltaTime;
} if (verticalInput != 0) {
position.x += verticalInput * MoveUnitsPerSecond * Time.deltaTime; } transform.position = position;
} } Why wont GetAxis work, the course i am going off of has this exact code but unity is saying that I cannot call GetAxis("Horizontal") from a monobehavior constructor
32 replies