Conventions and Syntax

Tutorial

·

Beginner

·

+10XP

·

5 mins

·

(6055)

Unity Technologies

Conventions and Syntax

Learn about some basic conventions and syntax of writing code - dot operators, semi-colons, indentation and commenting.

This tutorial is included in the Beginner Scripting project.

Previous: Variables and Functions

Next: If Statements

Languages available:

1. Conventions and Syntax

using UnityEngine;
using System.Collections;

public class BasicSyntax : MonoBehaviour
{
    void Start ()
    {
        //this line is there to tell me the x position of my object

        /*Hi there!
         * this is two lines!
         * */
        Debug.Log(transform.position.x);
        
        if(transform.position.y <= 5f)
        {
            Debug.Log ("I'm about to hit the ground!");
        }
    }
}

Complete this tutorial