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