Search Unity

Instantiated GameObjects spawn with velocity.

Discussion in 'Physics' started by Ken32, Jul 3, 2022.

  1. Ken32

    Ken32

    Joined:
    Nov 21, 2020
    Posts:
    4
    Hello all,

    I've come back to a project and appear to be having some issues when Instantiating game objects.

    The issue is that when they are instantiated, they spawn with velocity and are tossed around 10m from the spawn location.

    I've tried setting velocity and angular velocity to zero after instantiating but does not help.

    Troubleshooting
    I've tested this on a default 3D cube with an added Rigidbody (removing this of course does not result in the "throwing" of the object).

    Unity Version: 2020.3.18f1

    To show nothing funny going on, the code below is used to spawn the default 3D cube at a fixed position. Script is running on an empty game object, but the "throw" occurs even if I set a Vector3 as a defined location.

    Code (csharp):
    1.  
    2.  void Spawn()
    3.     {
    4.        
    5.         var x = Instantiate(spawnObject, this.transform.position, Quaternion.identity);
    6.        
    7.     }
    8.  
    9.  
    Any thoughts?

    Thank you in advance.
     
  2. Ken32

    Ken32

    Joined:
    Nov 21, 2020
    Posts:
    4
    Ignore thread.

    After testing on other projects and then at different positions much further away, I realised I had a very large spherical collider on an object causing the issue.