- Home /
need to reset object position somehow.plz help
i need help. I have a wall that pushes the player when the player collides with a trigger. To do that i animated the wall using an "object moving script" and have the wall object activate when the player collides with said trigger. I also made a trigger that deactivates the wall. All that worked out great and all but when the player dies and goes back, i want the wall to reset to it's original position since it's stuck in it's current position making it impossible to progress. I tried to make triggers that reset the wall object but i couldn't do it. Is there any way to ALSO reset the object's position when the player collides with activation trigger? Activation trigger script looks like this:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class activatelauncher : MonoBehaviour {
public GameObject launcher;
void OnTriggerEnter(Collider col){
{
if(col.gameObject.name == "player")
{
launcher.SetActive(true);
}
}
}
}
launcher is the wall object. Please help me. I'm bad at scripts.
Answer by Hellium · Feb 23, 2019 at 06:15 PM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class activatelauncher : MonoBehaviour
{
private Vector3 initialPosition;
public GameObject launcher;
void Start()
{
initialPosition = transform.position;
}
void OnTriggerEnter(Collider col){
{
if(col.gameObject.name == "player")
{
launcher.SetActive(true);
transform.position = initialPosition ;
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612192320im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Char moves along moving platform, but gets stuck. 1 Answer
Can't click gameobject when over another trigger? 1 Answer
solution with on trigger destroy 0 Answers
Restraining movement to camera bounds 1 Answer
Shuttle Runs & Counter 0 Answers