708's Wiki

Dudes of 708's knowledge base for getting started and tools we use

Edit the wiki on GitHub 708innovations/wiki

Visit our homepage dudesof708.com

Learning Unity


Back to homepagesoftware resources guideUnity setup guide


This is just how some of us learned how to use Unity. Your use case may be different.

FAQ

I’m getting a Unity package manager error with options Retry, Quit, and Continue! It mentions editing my package.json file and an error while resolving packages.

This is an internet connection issue with Unity’s analytics package. Go to your project folder’s Packages folder, and open package.json. Inside, find the line that says com.unity.analytics and delete it. Restart Unity, and you should be able to open the project now.

Footnotes

Footnote 1

Here is the source code of GhostManager.cs:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public struct GhostTransform {
    public Vector3 position;
    public Quaternion rotation;
    public GhostTransform(Transform transform) {
        this.position = transform.position;
        this.rotation = transform.rotation;
    }
}

public class GhostManager : MonoBehaviour {
    public Transform kart;
    public Transform ghostKart;
    public bool recording;
    public bool playing;
    public List<GhostTransform> recordedGhostTransforms = new List<GhostTransform>();
    private GhostTransform lastRecordedGhostTransform;
    void Start() {}
    void Update() {
        if (recording == true) {
            if (kart.position != lastRecordedGhostTransform.position || kart.rotation != lastRecordedGhostTransform.rotation) {
                var = newGhostTransform = new GhostTransform(kart);
                recordedGhostTransforms.Add(newGhostTransform);
                lastRecordedGhostTransform = newGhostTransform;
            }
        }
        if (playing == true) { Play(); }
    }
    void Play() {
        ghostKart.gameObject.SetActive(true);
        StartCoroutine(StartGhost());
        playing = false;
    }
    IEnumerator StartGhost() {
        for (int i = 0; i < recordedGhostTransforms.Count; i++) {
            ghostKart.position = recordedGhostTransforms[i].position;
            ghostKart.rotation = recordedGhostTransforms[i].rotation;
            yield return new WaitForFixedUpdate();
        }
    }
}

Footnote 2

Here’s how to install ProGrids, a plugin for Unity:

  1. From the toolbar, open Window > Package Manager.
  2. Search for ProGrids. ProGrids
  3. Click Install in the bottom right corner.