- Home /
Reset location on collision ?
Hi i'm pretty new to unity and i'm working on a university project and i'm making a game where you jump onto moving platforms in the sky and i was wondering how i would go about resetting the first person controllers location when you miss the platform because it just free falls, thanks.
Answer by _joe_ · Mar 27, 2015 at 09:23 PM
Make an empty gameobject and add a box collider to it and resize it (make it very big in x and z) and place it under your level. Tag this gameobject (let's say the tag is "Maplimit").
In your character controller do this:
void OnCollisionEnter(Collision c){
if(c.gameObject.tag == "Maplimit"){
//You can either use a new Vector 3
this.transform.position = new Vector3(0,0,0);
//or have a GameObject and get its position
this.transform.position = mySpawnGameObject.transform.position;
//Where mySpawnGameObject is a public GameObject variable that you assign from the inspector
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613191406im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
How to make Character Controller triggered collider? 1 Answer
Child object's collider (on a different layer) is interfering with parent Physics... 0 Answers
Can it be detect several colliders in the same gameObject? 0 Answers
Character's trigger collides with itself 2 Answers