Hello everyone,
I’ve recently started how to code on my own and I have some questions I can’t find answers to in my book. It’d be cool if you guys could help otherwise I’ll probably find it out eventually but there are certain things I’d like to learn right now :). Links with the answers would be nice if writing everything would take too long.
-
What’s the advantage of using the private function? Isn’t it better to be able to see all the commands in the console?
-
I thought all statements needed to end with a semi-colon. Why is that sometimes you’ll get things like this:
void Start()
{
characterCombat = CharacterCombat.Instance;
}
public void Initialize()
{
//startTime = Time.realtimeSinceStartup;
Show();
}
Void ends with () not with a ;. So I take it that void () isn’t a statement. What is it then?
- How do I integrate the source code to Unity? The programmer that joined disappeared and I can’t reach him although I’ve tried many times.
When I download the zip file from bit bucket I get the following:
I tried to open the source code in Unity but I can’t find out how. Do I need to integrate every single Asset individually in Unity?
- So I understand I need to declare a variable before using it. In the following case:
public class Clock : MonoBehaviour
{
public SpriteRenderer SpriteRenderer;
public Animator Animator;
//private float startTime;
private CharacterCombat characterCombat;
private Animator thisAnimator;
void Start()
{
characterCombat = CharacterCombat.Instance;
}
public void Initialize()
{
//startTime = Time.realtimeSinceStartup;
Show();
Is "public SpriteRenderer SpriteRenderer; the part where I declare a variable? According to my book, a variable begins with a lowercase so I guess in this case it’s a class, right? Why is SpriteRenderer showing up twice? I don’t understand.
-
Why is it that characterCombat doesn’t have a dot in between the two words and the other CharacterCombat.Instance does? Why isn’t there a . between Character and Combat? My book says that’s “dot syntax”…?
-
Why use float here and not integer (int)? :
public void Deinitialize()
{
//float elapsedTime = Time.realtimeSinceStartup - startTime;
//Debug.Log(string.Format("Elapsed Time: {0}s", elapsedTime));
Invoke("Hide", 1.0f);
- My book keep talking about “methods”, so googled the term and tried to find more information about it:
Where would the method be in there:
public class Clock : MonoBehaviour
{
public SpriteRenderer SpriteRenderer;
public Animator Animator;
//private float startTime;
private CharacterCombat characterCombat;
private Animator thisAnimator;
void Start()
{
characterCombat = CharacterCombat.Instance;
}
public void Initialize()
{
//startTime = Time.realtimeSinceStartup;
Show();
The statements are the lines ending with ;. A method is a code block containing a series of statements. So would line 2 to 13 be a method since it’s a code block containing statements?
According to my book:
So are the lines ending with () methods then? I understand a method refers to some lines of code. It’s sort of a substitute for a group of lines of code. Does that mean that Void Start () refers to some lines of code already written somewhere in the script? Or is it simply that what is between { } are methods?
Ok, that’s enough questions for now. I’m trying to pick up where the programmer left off and it’s very confusing at first.
Thanks for reading,
Z.