private void Start() { player = GetComponentInParent <Rigidbody>(); pMovement = player.GetComponent <PlayerMovement>(); myCapsuleCollider = player.GetComponentInParent <CapsuleCollider>(); positionOfAnchor = transform.TransformDirection(Vector3.up); positionOfAnchor.y = maxHookShotDistance; fishRef = player.GetComponentInChildren <RefScript>(); anim = player.GetComponentInChildren <Animator>(); capsuleHRef = myCapsuleCollider.height; hookLineRenderer = GetComponent <LineRenderer>(); }
//script is a component - access script components on other game objects, takes type as a parameter //initialise variables private void Awake() { refScript = GetComponent <RefScript>(); refScriptAlt = otherGameObject.GetComponent <RefScriptAlt>(); boxCol = otherGameObject.GetComponent <BoxCollider>(); }