26/09/2021

[Unity] Fury Farm

A sample 3D shooter game made with Unity.

Get the code from the repo or play online.

The animals have gone mad, defend your farm from their rage.

Controls:

AD - move left/right

SPACE - shoot

R - restart level

Q - quit

Interesting notes:

  • FindObjectOfType<OBJECT_NAME>(); get an object in a script without binding it in input
  • "this" is actually gameObject within a script
  • InvokeRepeating("METHOD_NAME", START_DELAY, REPEAT_RATE); added to an Awake or Start method, will ensure the given method is called repeatedly according to configuration
  • Random.Range(MIN, MAX) gives a random float between MIN and MAX both inclusive
  • WebGL default screen size is 960x600, the game default aspect is "Free Aspect" (top left of Game tab), change in File->Build Settings->Player Settings the resolution for WebGL to match a different one and set the Game aspect to the same to test how would it look like on the user screen
  • Cooldown logic can be added by tracking a float variable and updating it with -Time.deltaTime every frame, then checking if its value is less than some threshold to allow the player to execute the action again

No comments:

Post a Comment

With great power comes great responsibility