Variables and Functions

Tutorial

·

Beginner

·

+10XP

·

10 mins

·

(8364)

Unity Technologies

Variables and Functions

What are Variables and Functions, and how do they store and process information for us?

This tutorial is included in the Beginner Scripting project.

Previous: Scripts as Behavior Components

Next: Conventions and Syntax

Languages available:

1. Variables and Functions

using UnityEngine;
using System.Collections;

public class VariablesAndFunctions : MonoBehaviour
{   
    int myInt = 5;
    
    
    void Start ()
    {
        myInt = MultiplyByTwo(myInt);
        Debug.Log (myInt);
    }
    
    
    int MultiplyByTwo (int number)
    {
        int result;
        result = number * 2;
        return result;
    }
}

Complete this tutorial