Возникла проблема с триггер он не работает:
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WoterVis : MonoBehaviour
{
public AudioSource audio;
public GameObject br;
void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Enter" + collision.gameObject);
GameObject oj = collision.gameObject;
Rigidbody2D rb = oj.GetComponent<Rigidbody2D>();
Vector3 v3Velocity = rb.velocity;
var speed = rb.velocity.magnitude;
Vector3 vector = new Vector3(oj.transform.position.x, -5.6f, 27.41f);
if (speed > 5) { audio.Play(); Instantiate(br, vector, Quaternion.EulerAngles(-90, 0, 0)); }
}
}
using System.Collections.Generic;
using UnityEngine;
public class WoterVis : MonoBehaviour
{
public AudioSource audio;
public GameObject br;
void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Enter" + collision.gameObject);
GameObject oj = collision.gameObject;
Rigidbody2D rb = oj.GetComponent<Rigidbody2D>();
Vector3 v3Velocity = rb.velocity;
var speed = rb.velocity.magnitude;
Vector3 vector = new Vector3(oj.transform.position.x, -5.6f, 27.41f);
if (speed > 5) { audio.Play(); Instantiate(br, vector, Quaternion.EulerAngles(-90, 0, 0)); }
}
}
И вот в чём прикол - он не работает только на один определённый объект. Компоненты объекта -
https://yadi.sk/d/NffI28dkaci-PQ