public class Movement : MonoBehaviour {
public Vector2 movement;
private Rigidbody2D rb;
public GameObject text;
private bool isMove = true;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
if(isMove) rb.MovePosition((Vector2)transform.position + movement);
}
private void Update()
{
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Main")
{
isMove = false;
transform.SetParent(other.transform);
}
if(other.tag == "GameOver")
{
Debug.Log("GameOver");
text.SetActive(true);
// text - пустой объект к которому привязан текст
}
}
}