Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

why is my instance not acting the same as the prefab?

Discussion in '2D' started by isanvel, Aug 5, 2019.

  1. isanvel

    isanvel

    Joined:
    Mar 21, 2019
    Posts:
    15
    the prefab is the ball falling, and the instance ball does not fall at all.
    i've been trying to figure it out what it is, but i don't see any problems
    can you guys help me out please?

    https://imgur.com/a/jroAW3H
     
  2. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,642
    Do you have collision code that deletes the balls when they touch something? Are they deleting each other when they spawn quickly?

    If not, pause the game and take a look at the spawned ball's inspector and make sure everything looks right.
     
  3. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    49
    They have on trigger, when they trigger with the box they get destroy
    But sometimes the ball instance gets destroyed for some reason
     
  4. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,642
    What's the code for the trigger?
     
  5. isanvel

    isanvel

    Joined:
    Mar 21, 2019
    Posts:
    15
    private void OnTriggerEnter2D(Collider2D collision)
    {
    Destroy(gameObject);
    }
     
  6. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,642
    Is that on the box or the ball? That code will destroy the object when the trigger hits anything at all.

    If your spawner just spawns just 1 ball, does it still have issues?
     
  7. isanvel

    isanvel

    Joined:
    Mar 21, 2019
    Posts:
    15
    i acutally fixed this with physics 2d, now im getting other problem where prefab gets destroyed
    and instance won't respawn