How do I use my colliderObject in the update function?

I have been working on a script the past few hours and I can’t seem to be able to figure out how to use a ‘colliderObject’, obtained through a collision, in my update function.

So hereby the question; How would I do this? I know I would normally store it in an variable outside of my functions, but int he case of an colliderObject I don’t know how to do this.

My code:

using UnityEngine;
using System.Collections;

public class inAndOut : MonoBehaviour {

	private bool colliding = false;

	// Use this for initialization
	void Start () {

	}

	void OnTriggerEnter (Collider colliderObject){

		if(colliderObject.transform.gameObject.name == "Player")
		{
			Debug.Log ("press E");

			colliding = true;

		}

	}

	// Update is called once per frame
	void Update () {

		if(Input.GetKeyDown (KeyCode.E) && colliding == true) {
		
			colliderObject.transform.parent = this.transform;
			this.camera.camera.enabled = true;
			colliderObject.camera.camera.enabled = false;
		
		}

	}
}

I hope someone here will know how to do what I aim to, thanks already if you do.

Given what you are doing here, I’d probably save the transform, not the collider, but you could save the collider. Here is a bit of rewrite of your code to demonstrate:

using UnityEngine;
using System.Collections;

public class inAndOut : MonoBehaviour {
	
	private Transform player;

	void OnTriggerEnter (Collider colliderObject){
		
		if(colliderObject.name == "Player") {
			Debug.Log ("press E");
			player = colliderObject.transform;
		}
	}
	
	void Update () {
		
		if(Input.GetKeyDown (KeyCode.E) && (player != null)) {
			player.parent = this.transform;
			this.camera.camera.enabled = true;
			player.camera.enabled = false;
		}
	}
}