So, for a while now this has been bugging me, when you update the name of an object in Unity3D, it breaks the reference to the object’s properties in the timeline if you are animating them.
The only way to fix it seemed to be to create a new property from the renamed object and then copy the keyframes to it, which is really time-consuming and not ideal. The ideal solution would be that you rename the layer and it recovers the reference, or drag and drop an object to the missing object or right click and select a new object.
Well, today I found a slight ray of hope, in my frustration at having some more broken references, I discovered after double clicking the objects name 3 times, it actually became selectable and it is possible to edit the field name and recover the link to the object! Although the selection is broken, I’m glad it exists and hopefully this is something Unity will fix soon 🙂
In my new game I need to be able to give an object in motion a new force (same magnitude) in a random direction with a button press. Here’s my C# solution using Coroutines.
Its working perfectly for me and solves the weird physics problem with stopping/starting using rigidbody.isKinematic.
All these code snippets are in the script attached to the object:
Vector3 eulers = Vector3.zero;
private bool waiter;
yield return new WaitForSeconds(0.0f);
eulers = transform.eulerAngles;
eulers.x = Random.Range(0,360);
transform.eulerAngles = eulers;
rigidbody.isKinematic = true;
yield return new WaitForSeconds(0.01f);
rigidbody.isKinematic = false;
rigidbody.AddForce(transform.forward * shotPower);
private void Waits()
waiter = true;
if(waiter == true)
waiter = false;