C# Addendum
This was another very straightforward port to C#. The only thing that could potentially trip you up is realizing that in C# version of the FallingObject script, the built-in array's Length
property starts with a capital L, while Unity JavaScript uses a lowercase l.
Here's the code:
FallingObjectCSharp.cs
using UnityEngine; using System.Collections; public class FallingObjectCSharp : MonoBehaviour { public GameObject prefab; public int speed; public AudioClip[] audioClips; void Update () { transform.position = new Vector3(transform.position.x, transform.position.y - speed * Time.deltaTime, transform.position.z); if(transform.position.y < 0) { audio.PlayOneShot(audioClips[Random.Range(0,audioClips.Length)]); Instantiate(prefab, transform.position, Quaternion.identity); transform.position = new Vector3(Random.Range(0,60), 50, -16); } } }
CharacterCSharp.cs
using UnityEngine; using System.Collections; public class CharacterCSharp...