Home > other >  Unity - Instantiate current gameObject while going
Unity - Instantiate current gameObject while going

Time:09-27

There is a problem that I haven't been able to solve for a few days, how do I clone the moving object and make the clone follow the original object letter by letter?There is a problem that I haven't been able to solve for a few days, how do I clone the moving object and make the clone follow the original object letter by letter?

This one main Instantiate

public static Instantiate Instance;


public Rigidbody Ball;

//FixedUpdate ile test et
private void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        Rigidbody clone;

        clone = Instantiate(Ball, transform.position, transform.rotation);
        clone.velocity = transform.TransformDirection(Vector3.forward * 25);
    }
}

this on clone

public Rigidbody Ball;

public Transform mainPos;

private void Update()
{
    
}
private void OnTriggerExit(Collider other)
{
    if (other.CompareTag("Gate"))
    {
        Rigidbody clone2;

        clone2 = Instantiate(Ball, mainPos.position, mainPos.rotation);
        clone2.transform.parent = gameObject.transform;
    }
}

CodePudding user response:

I am pretty sure you are setting the clone's parent to itself. One way you might be able to fix your problem, is by setting the clone's parent, to the original game object.

  • Related