stalker x
Hectopat
- Katılım
- 1 Nisan 2020
- Mesajlar
- 428
- Çözümler
- 3
Unity'de buton ile açılan kapı tarzı bir şey yapacağım ve yazdığım kodda her şey calışıyor sadece çalışmayan tek şey: Hem kutu hem de karakter Trigger'ın üzerinde iken ikisinden herhangi biri Trigger'dan çıkınca animasyon ıdle haline dönüyor. mesela kutu butonun üstünde iken ben karakter ile butonun içinden geçip cıktığımda kutu hala butonun üstünde olmasına rağmen buton eski haline dönüyor. If yapısının içerisine && koyup denedim olmadı.
[CODE lang="csharp" title="Buton Kodu" highlight="24"]public class ButtonAnimation : MonoBehaviour.
{
public Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
private void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Box")
{
animator.SetTrigger("Down");
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Box")
{
animator.SetTrigger("Idle");
}
}
[/CODE]
[CODE lang="csharp" title="Buton Kodu" highlight="24"]public class ButtonAnimation : MonoBehaviour.
{
public Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
private void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Box")
{
animator.SetTrigger("Down");
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Box")
{
animator.SetTrigger("Idle");
}
}
[/CODE]
Son düzenleyen: Moderatör: