I
I
Ilya_malet2021-11-02 17:29:09
Unity
Ilya_malet, 2021-11-02 17:29:09

Why doesn't the object spawn?

Hello, help me understand why the _fractions object is not created.

using UnityEngine;

public class PurpleEnemy : Enemy
{
    [SerializeField] private GameObject _fractions;

    private float _distantion;

    private void Update()
    {
        _distantion = Vector2.Distance(transform.position, _target.transform.position);

        if (_distantion <= _distantionForAtack)
        {
            Burst();
        }
    }

    private void Burst()
    {
        Destroy(gameObject);
    }

    private void OnDestroy()
    {
        Instantiate(_fractions, transform);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crebor, 2021-11-02
@Ilya_malet

Instantiate(_fractions, transform);
After all, it should be

Instantiate(_fractions, transform.position,transform.rotation);

Try.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question