getting a collisions position and rotation for outside functions

I and trying to use the “ClosestPointOnBounds” transform & position in a outside function (In this script it would be the Update function).

using UnityEngine;
using System.Collections;

public class ConsoleLogVectorPos : MonoBehaviour {
	
	//--------------------
	public Rigidbody snowtrailPrefab;
	//--------------------
	
	// True Or False Declare
	public bool ToF = false;
	
	
	//------------TriggerEnter---------------
	public void OnTriggerEnter(Collider other)
	
	{
		ToF = true;
		Debug.Log("Entered Val is " + ToF);
		
		
	}
	
	
	//------------TriggerStay----------------
	//Not used but exist in case it's needed
	public void OnTriggerStay(Collider other)
	
	{
		//ToF = 1;
		//Debug.Log("Staying Val is " + ToF);
		
		Vector3 collisionPoint = other.ClosestPointOnBounds(transform.position);
		//Debug.Log("Collision of X,Y,Z is: " + collisionPoint.ToString("F4"));
		
		
		
	}
	
	//-------*--Update Method--*------------
	public void Update()
		
	{
		if(ToF == true)
			
		{
			
			Rigidbody meshinstance;
			meshinstance = Instantiate(snowtrailPrefab, Vector3.other.position, Vector3.other.rotation) as Rigidbody;
			
		}
		
	}
	
	
	//------------TriggerExit---------------
	public void OnTriggerExit(Collider other)
	
	{
		ToF = false;
		Debug.Log("Exited Val is " + ToF);
		
	}
	
	
}

I just tried this as an alternative ‘get around’ which didnt work.

//-------*--Update Method--*------------
	public void Update()
		
	{
		if(ToF == true)
			
		{
			Vector3 collisionPoint = other.ClosestPointOnBounds(transform.position);
			
			Rigidbody meshinstance;
			meshinstance = Instantiate(snowtrailPrefab,collisionPoint.postion ,collisionPoint.transform ) as Rigidbody;
			
		}
		
	}

Is there any way I can stick the vector3 position into a readable term as well as the collisions rotation?? Im still looking around for answers on google :confused:

Your work around doesn’t work because “other” doesn’t exist in that context. If you want to be able to use that closest point in the update function of that same class, just put a variable outside the scope of the OnTriggerStay and store the vector there.

Vector3 collisionPoint;

public void OnTriggerStay(Collider other)
{
   collisionPoint = other.ClosestPointOnBounds(transform.position);
}

Then you can use that in your Update method:

public void Update()
{
   if(ToF == true)
   {
     Rigidbody meshinstance;
     meshinstance = Instantiate(snowtrailPrefab,collisionPoint.postion ,collisionPoint.transform ) as Rigidbody;
   }
}

Maybe I’m misunderstanding the question though?

public void OnTriggerStay(Collider other)

    { 
       Vector3 collisionPoint = other.transform.position;
    }