Advertisement

I Know Nothing and I want to change that

Started by May 23, 2018 07:33 PM
43 comments, last by TheGreech 6 years, 6 months ago
6 minutes ago, Scouting Ninja said:

That would be very slow, if all your code kept running at the same time it would take too long.

The way that code works it returns a bool when called, it is known as a function, a small program if you want:



//This is how it is used
Health.checkIfPlayerDied();

Health.currentHealth -= 100;

//It is only called when we ask for it
if(Health.checkIfPlayerDied() == true){
  print("Sorry, you died");
}

 

It is for commenting. It tells the computer to ignore this line because it is for humans to read.

Okay so when does it run. For instance does it run each time the player takes damage?

Yes, you would call it every time the player loses health.

In Unity there is a Update() function in your mono scripts. That is where realtime stuff is done inside of. So in there you would damage a player, check if it lived by calling this etc.

A basic Unity script looks like this:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

This part: public class NewBehaviourScript : MonoBehaviour tells you it is a Mono script and it already has functions like Start() and Update() inside for you.

Advertisement
3 minutes ago, Halpmelurngewd said:

Okay so when does it run. For instance does it run each time the player takes damage?

If a player attacks an orc enemy then you would do the attack, check the health and decide if the orc is alive or dead. You only call such functions on a as needed basis.

The better you are at creating solutions to problems, and the more logical you are the easier this will all come, but it's all useless unless you know how to use the tools available (such as a programming language).

Your best bet is to get a book and start from front to back with something like C#. You can try Head First C#, or C# in a Nutshell.

Otherwise check out MSDN:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/

https://www.microsoft.com/net/learn/in-browser-tutorial/1

I also do not recommend you start with game programming (using engines, apis, libraries related to game dev) until you have enough general programming knowledge and experience. You can still learn general programming with games in mind, but at a more simple level (text based).

You will just add to the confusion if you jump in too deep at the start without a strong foundation. Pick up a book, and write as much code as you can. Make alterations to the code you've learned, and take those concepts to create mini projects.

Programmer and 3D Artist

17 minutes ago, Scouting Ninja said:

Yes, you would call it every time the player loses health.

In Unity there is a Update() function in your mono scripts. That is where realtime stuff is done inside of. So in there you would damage a player, check if it lived by calling this etc.

A basic Unity script looks like this:



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

This part: public class NewBehaviourScript : MonoBehaviour tells you it is a Mono script and it already has functions like Start() and Update() inside for you.

Okie dokie I'm off to study a little and practice thanks for everything

2 hours ago, Scouting Ninja said:

Yes, you would call it every time the player loses health.

In Unity there is a Update() function in your mono scripts. That is where realtime stuff is done inside of. So in there you would damage a player, check if it lived by calling this etc.

A basic Unity script looks like this:



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

This part: public class NewBehaviourScript : MonoBehaviour tells you it is a Mono script and it already has functions like Start() and Update() inside for you.

Hey I have a question. Should my code always start with #include<iostream> or does it depend on the situation?

If you're using C++ and you want to use the iostream header, then you'll have to include it. It doesn't matter if it's above other includes or in between other includes.

I hope you're not learning C++ as your first language. I would highly discourage this.

Programmer and 3D Artist

Advertisement
Just now, Rutin said:

If you're using C++ and you want to use the iostream header, then you'll have to include it. It doesn't matter if it's above other includes or in between other includes.

I hope you're not learning C++ as your first language. I would highly discourage this.

Why not?

Learning C++ as your first language is like deciding to climb Mount Everest as your first mountain. It can be done but is very harsh and many loose hope that way.

C++ is a extremely difficult language, it does no cleaning up for you, is one of those languages that believes the programmer is always right and has no safety systems in place.

 

Learning C++ first could be confusing. Most C++ tutorials will expect you already learned the basics of programming; they will not explain to you what you are doing or why.

It could be why you have been having such a hard time to understand programming.

 

It's recommended you start with Python, C# or even JavaScript, any other object orientated language will do.

6 minutes ago, Scouting Ninja said:

Learning C++ as your first language is like deciding to climb Mount Everest as your first mountain. It can be done but is very harsh and many loose hope that way.

C++ is a extremely difficult language, it does no cleaning up for you, is one of those languages that believes the programmer is always right and has no safety systems in place.

 

Learning C++ first could be confusing. Most C++ tutorials will expect you already learned the basics of programming; they will not explain to you what you are doing or why.

It could be why you have been having such a hard time to understand programming.

 

It's recommended you start with Python, C# or even JavaScript, any other object orientated language will do.

Got ya. The only reason I was trying to learn c++ first was because I was going to use unreal engine. Is there one that uses C# that is equivalent

1 minute ago, Halpmelurngewd said:

uses C# that is equivalent

There is nothing equivalent with Unreal. :) However if you are starting with Unreal you should be using Blueprints, not C++ till you have a grasp of programming.

However Unreal like C++ isn't beginner friendly.

You can start with Unreal, there is lot's of bonuses to doing so, but it will be a rocky road at the least.

 

Since you are going to college you should probably start with Unity, it uses C#. It's the one most colleges use to train developers. Unity and C# is much easier to learn than Unreal and C++.

Because Unity is 10 times easier to use than Unreal and has 65-70% of the power, it is Unreal's biggest competitor. Or at least Unreal is Unity's biggest competitor.

 

Starting with Unity and switching to Unreal (or whatever engine is popular at the time) is a good strategy.

This topic is closed to new replies.

Advertisement