- Home /
How to get object's position where he will exit the trigger?
Hey, is there any posible way to know where object will exit the trigger. For example, I have an object, which is moving, he enters trigger and I want to calculate and know in what position he will exit trigger. Trigger isn't moving and the object is moving forward, so he will exit the trigger only on the other side of the trigger. Oh, and the trigger is circle-shaped if it has any significance.
You can use gameobject.transform.position to get the position of your game object everywhere you want. The example available here: https://docs.unity3d.com/Documentation/ScriptReference/Transform-position.html
Answer by Ermarrero · Apr 07, 2014 at 01:37 AM
use OnTriggerExit event and record the gameObjects position. It wont calculate when the object will exit but at least it tells you when it exited. Something like this should work:
JavaScript:
var position : Vector3;
function OnTriggerExit (col : Collider)
{
position = col.transform.position;
Debug.Log(position);
}
C#
public Vector3 position;
void OnTriggerExit(Collider col)
{
position = col.transform.position;
Debug.Log(position);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613142056im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
creating an asteroid-like game in 3d 0 Answers
how to set rotation / position of an object on trigger? 2 Answers
Get position of collision with triggers? 1 Answer
Instantiate breaking at certain positions? 0 Answers
transform postion trigger problem HELP! 0 Answers