[Solved] Throwing an exception at line16 [closed]

Instead of ch = Convert.ToChar(Console.ReadKey()); You should put it as ch = Console.ReadKey().KeyChar; Since ConsoleKeyInfo instance which is returned by Console.ReadKey() can’t be just converted into char 4 solved Throwing an exception at line16 [closed]

[Solved] Make inventory that receives purchased items from the shop system

You can use events to make your scripts “communicate” independently. First you need the gameevents. Make sure you have the script on a gameobject in your scene: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameEvents : MonoBehaviour { public static GameEvents gameEvents; private void Awake() { gameEvents = this; } public event … Read more

[Solved] Which is more preferable? Performance or Memory while spliting a string in C#? [closed]

There’s no reason to do a computation that has the same result multiple times, especially if it involves memory allocations. You’re correct in that your first snippet has worse time and memory performance. Every call to split will iterate over the string (probably the fastest part of all that), allocate two new arrays and copy … Read more

[Solved] What would void Start() be in pseudocode [closed]

It depends on what you mean by “pseudocode”. Most people just mean that it is generally simpler and more natural-English-looking, with relaxed syntax when compared to “real” code. Generally in that case I would use something like run_at_start and run_30_times_a_second to cover what Unity does. However if you have a specific definition of “pseudocode” that … Read more

[Solved] Unity ‘Transform does not contain a definition for Position’ [closed]

C# is a case sensitive programming language. You wrote transform.Position instead of transform.position. You also tried to make operations on transform.position which is invalid. If you want to make an operation on the position then you must declare x or y. So, transform.position.x + 5 is valid However, transform.position + 5 is invalid. solved Unity … Read more

[Solved] Player getting stuck on the map

You should check that the point you are going is not outside your map. I think that when you are adding forces to the rigidbody you can add “too much” forces and that rigidbody collides with something and after that it get stacked. Edit: Check the OnCollisionEnter, OnCollisionStay and Exit also the triggers. http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html 2 … Read more

[Solved] Format DateTime without converting it to a string in c#? [closed]

I think there is a bit of a confusion here what the string concatenation does to your values. It is nothing less than simply using the default format for a parameterless ToString()! Each of your strings like Debug.Log(“currentTime: ” + currentTime); basically internally implicitly equal Debug.Log(“currentTime: ” + currentTime.ToString()); In that case the ToString() without … Read more

[Solved] New to C#, can anyone explain to me how enums and setting variables for enums works? [closed]

An enum is basically a special type that lets you define named values. You’re creating a named type just as you would if you were defining a class. What your code is actually doing is first defining your enumerated type called States with all the possible named values, then declaring a variable “myState” using the … Read more

[Solved] can i use the 2D code in unity into my 3D project?

In your case, I think you can. Let’s say for example you have some method: private static void PowerUp(List<Monster> monsters) { // do smth like: foreach(var m in monsters) { m.Invulnerable(); { } In that case, it’s totally fine reuse your code but if it’s something 3D specific you may not be able to reuse … Read more