Odin
Odin
Explore posts from servers
CC#
Created by Odin on 7/8/2023 in #help
❔ Truncate
how do I Truncate a float to an int, I tried this

public int maxGap = 4;


maxGap = 4 + decimal.Truncate(player.position.x/500);

public int maxGap = 4;


maxGap = 4 + decimal.Truncate(player.position.x/500);
and it says
Argument 1: cannot convert from 'float' to 'decimal' [Assembly-CSharp]
Argument 1: cannot convert from 'float' to 'decimal' [Assembly-CSharp]
I really need to know how to truncate now
14 replies
CC#
Created by Odin on 5/12/2023 in #help
❔ 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
CC#
Created by Odin on 4/1/2023 in #help
❔ How do i write hello world
All I know is that Console.WriteLine writes hello world so how do i write hello world? Like this? Console.WriteLine(“Hello world”)?
5 replies
CC#
Created by Odin on 3/29/2023 in #help
❔ 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
32 replies