So what does this word “static” do to variables and methods? Well a couple of things.

  1. static variables and methods that are public are accessible from anywhere without having to first reference or instantiate the class that they are in. Note though that if they are private, they can not.
  2. They make variables class variables, rather than instance variables. This comes in handy with games especially when you are creating multiple enemies or bullets or obstacles and you want to keep a total count of them. Rather than each instance of the enemy/bullet/obstacle keeping a count, the class as a whole keeps count.
using UnityEngine;
using System.Collections;


public class Obstacle
{
    //Static variables are shared across all instances of a class.
    public static int obstacleCount = 0;

    public Obstacle()
    {

    }

    static public Obstacle SpawnObstacle()
    {
        //Increment the static variable to know how many
        //objects of this class have been created.
        obstacleCount++;

        GameObject oGO = Instantiate<GameObject>(GameManager.ObstacleSO.GetObstaclePrefab());
        Obstacle obst = oGO.GetComponent<Obstacle>();
        return obst;
    }
}

 

Now one of the cool things about having a static method is that you can reference them directly and I’ll show you the code for that here.

using UnityEngine;
using System.Collections;

public class GameManager
{
    void Start()
    {
        for (int i = 0; i < 3; i++)
        {
            Obstacle obst = Obstacle.SpawnObstacle();
            Vector3 pos = ScreenBounds.RANDOM_ON_SCREEN_LOC;
            obst.transform.position = pos;
        }

        //You can access a static variable by using the class name
        //and the dot operator.
        int x = Obstacle.obstacleCount;
    }
}

 

Thank you Unity Answers for giving me the low down on this one. Read the full thread HERE

eric5h5 gives us a quick answer

Update runs once per frame. FixedUpdate can run once, zero, or several times per frame, depending on how many physics frames per second are set in the time settings, and how fast/slow the framerate is.

And duck gives us a further explanation

FixedUpdate should be used when applying forces, torques, or other physics-related functions – because you know it will be executed exactly in sync with the physics engine itself.

Whereas Update() can vary out of step with the physics engine, either faster or slower, depending on how much of a load the graphics are putting on the rendering engine at any given time, which – if used for physics – would give correspondingly variant physical effects!

The exception to this would be that if your scene was putting such a load on the physics engine that it approaches the point where it becomes impossible to execute the required number of physics time steps to keep up to speed with ‘real time’. This means that your game has become impossible to simulate in real time – and in this case you need to seriously think about redesigning your game! This can happen if you have large numbers of complex objects (eg, rigidbody mesh colliders) all clumped together so you have lots of many-to-many collisions occuring each step.

To use the cross platform input manager you need to make sure you have the Standard Assets Package included in your Unity project. To import it, use these instructions

https://docs.unity3d.com/560/Documentation/Manual/AssetPackages.html


Ensure that CrossPlatformInput is selected in both the “Editor” and “Standard Assets” folders.

Open up the Project Setting > Inputs to define all of the controls

To refer to the CPI from your class file you must include it at the top with

 using UnityStandardAssets.CrossPlatformInput;

Then you can reference it directly

 CrossPlatformInputManager.GetAxis("Horizontal");