Search Unity

Instantiated GameObject's WheelJoint2D not working; why?

Discussion in 'Scripting' started by JanDawid, Sep 1, 2014.

  1. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    So I have a wheel-like object with a WheelJoint2D (which is joined to a parent object with a rigidbody2D), its motor is set as 500 for motor speed, and 10000 for max torque. It's saved as a prefab (the parent with the child object which has the WJ2D), and I have another gameobject which spawns these (the script passes in the prefab and instantiates the wheel). The problem is that when I put the wheel prefab itself on the scene and play the game, the wheel works like it should (goes off rolling around). However, when the generator instantiates the prefab, the parent object is spinning, however the child object (the wheel) is not. Until I pause the game, crank up the motor speed to higher than what it is in the prefab, it doesn't move. Why is the prefab rolling around like it should and why is the prefab when it's instantiated not moving at all?

    Eg.jpg