Code test

using UnityEngine;
using System.Collections;

public class Player_Weapons : MonoBehaviour {

    // Public variables assigned in Unity
    //Transform handRight;
    //Transform handLeft;
    public GameObject weaponPrimary;
    public GameObject weaponSpecial;
    public Transform muzzlePosition;
    public Projectile_V1 projectile;
    public Transform handRight;
    public Transform handLeft;

    // AWAKE SETUP
    void Awake() {
        handRight = transform.Find("Hand_R");
        handLeft = transform.Find("Hand_L");
    }

    // START INITIALIZATION
    void Start () {
        Debug.Log("START: Player_Weapons");
        //instanciateGun(weaponPrimary, handRight);
        //instanciateGun(weaponSpecial, handLeft);
        //tester();
    }
    
    // UPDATE
    void Update () {
    }

    // Instanciate gun prefab at hand position
    void instanciateGun(GameObject weapon, Transform hand) {
        GameObject newGun = Instantiate(weapon, hand.position, hand.rotation) as GameObject;
        newGun.transform.parent = hand;
    }



//	void tester() {
//		// Transform for just the GameObject "Hand_R"
//		Transform trans = transform.Find("Hand_R");
//		GameObject gameObject = trans.gameObject;
//		Debug.Log("FOUND: " + trans);
//
//		// Recursively list all child transofrms
//		Transform[] transforms = GetComponentsInChildren<Transform>();
//		foreach (Transform eachTransform in transforms) {
//			Debug.Log("ALL: " + eachTransform.name);
//		}
//	}
}

FUZZYGOAT © 2018