When I instantiate a ragdoll after my target NPC is killed, it keeps lurching forwards toward my character, even though the same object created in blank space correctly flies away from its facing. Any ideas? Script below. Code (CSharp): public Rigidbody mySpine1; public Vector3 myForwardVector; public Vector3 myUpVector; public Vector3 myForceVector; public float myBackForce = 500.0F; public float myUpForce = 1000.0F; public bool knockBackStarted; public float startTime; public float delayTime = 0.1F; void Start() { Destroy(gameObject, timeToLive); startTime = Time.time; knockBackStarted = false; } void Update() { if(Time.time >= startTime + delayTime && !knockBackStarted) { knockBackStarted = true; myForceVector = myBackForce * Vector3.forward * -1.0F + myUpForce * Vector3.up; mySpine1.AddForce(myForceVector); } }
If you add code-tags around the code, you make it easier to read and people might be more willing to help you. https://forum.unity.com/threads/using-code-tags-properly.143875/