Ejemplo n.º 1
0
 public void Awake()
 {
     // Delete any extra copies of script not attached to the GameObject with the GameManager
     if (singleton == null)
     {
         singleton = this;
     }
     else
     {
         Destroy(this);
         return;
     }
     this.enabled = false;
 }
Ejemplo n.º 2
0
    void Awake()
    {
        resetSwing    = true;
        rb            = GetComponent <Rigidbody>();
        col           = GetComponent <Collider>();
        hookAnchor    = new GameObject().transform;
        grappleAnchor = new GameObject().transform;
        state         = GetComponent <ColorState>();
        animator      = GetComponent <Animator>();
        arms          = GetComponent <PlayerArmController>();
        player        = GetComponent <PlayerMovement>();

        // set up grapple hook line and effect
        line                     = gameObject.AddComponent <LineRenderer>();
        line.enabled             = false;
        line.materials[0].shader = Shader.Find("Unlit/GrappleEffect");
        line.materials[0].SetColor("_Color", ColorState.RGBColors[state.currentColor]);
        line.startWidth = 0.1f;
        line.endWidth   = 0.15f;

        state.onSwap += (GameColor a, GameColor b) => line.materials[0].SetColor("_Color", ColorState.RGBColors[b]);;
    }