- Home /
toggling isKinematic not working Unity5, works in 4.6.6
I'm using an isKinematic=true toggle to to "teleport" an object to another location, then toggle it back to isKinematic=false in order to set it's rigidbody velocity to keep it moving. This has been working great in all versions of unity4.
In Unity 5 its not working. Once teleported to the new location, setting isKinematic=false fails and the object sits still at the new location. Is there any reason this would be an issue with unity 5?
my code on trigger enter:
hit.gameObject.rigidbody.isKinematic=true;
hit.gameObject.rigidbody.position = otherTeleporter.rigidbody.position;
on trigger exit:
hit.gameObject.rigidbody.isKinematic=false;
hit.gameObject.rigidbody.velocity.y = fallSpeed;
Answer by zezba9000 · Jul 31, 2015 at 12:01 AM
Hey posted about this in the Reign-Studios forums. So you're trying to make one object get stuck in another correct?
If possible could post the scripts or sample scripts so i can understand what is going on in context?
If you want to make two objects stick into one another you're going to have to keep track of there last position in the Update or FixedUpdate method BEFORE OnTriggerEntered is called. As you want it to "visually" look accurate. In this way you can set a flag telling the Update method to reset its last known visual or physical position and disable its rigidbody or remove the component in the Update method. Doing it in the OnTriggerEntered method will unpredictable results.