- Home /
Question by
Wesley21spelde · Jan 22, 2016 at 09:47 AM ·
scripting problemtrigger
transpoter not working!
Het guys this is not working
i linkt the together by putting transporter A in the slot From B and B in to A
The only problem is that when i enter the trigger of A it transports me To B and Back becouse i instandly trigger the trigger Form B
for unity 5.3
using UnityEngine;
using System.Collections;
public class TelePorter : MonoBehaviour
{
public Transform WeGoToTransorter;
public GameObject Trigger_Other;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
Trigger_Other.SetActive(false);
other.transform.position = WeGoToTransorter.transform.position;
}
void OnTriggerExit(Collider other)
{
//This is Not working it doing a pinpong effect
//Trigger_Other.SetActive(true);
}
}
Comment
Answer by Guhanesh · Jan 22, 2016 at 01:27 PM
The collider's transform.position is changed to outside the collider in OnTriggerEnter,so OnTriggerExit is also called along with it causing a ping pong effect.
Your answer
Follow this Question
Related Questions
Animator Trigger Not Working 1 Answer
2D Platformer - Picking Up Items & Storing Them C# 0 Answers
What is the best way to update array in runtime? 3 Answers
Play animation of FPS player after hitting trigger 2 Answers
OnTriggerEnter causing lag spike? 0 Answers