Help convert kinematic style movement to Forces.

Hi, sorry to bother you guys. I’ll get to the point: I have this code for moving an object towards a point, it also slowly turns the object towards the target. So, instead of moving in a straight line, the object can curve very nicely, and stray slightly from the path , which looks and feels very nice and gives a more natural movement, specially for flying objects following nodes. But, recently I’ve been trying to use the code on objects with a rigid body that needs to be nonKinematic during most of runtime (when the object is not flying and just lies in the floor).

Now, I’ve been changing IsKinematic to true before I start to move the object (right before the loop), and at that point it works, but for some reason, when the code stops and I set IsKinematic back to false, my code is never able to change the rigidbody back to true ever again (if I call the very same function again, the object just wobbles and the inspector shows the rigidbody is not kinematic). Anyone has any idea why that happens? I’m pretty sure I’m not changing IsKinematic anywhere else.

EDIT: Nevermind the above, but if you can help me to get this same effect using forces I’ll be really tahnkful. :slight_smile:

Anyway, I know that there’s a penalty for changing Iskinematic in a rigid body, so, else, can anyone tell me what would be the proper way to mimic the same motion but based on physics forces? I must say I’ve barely used physics based motion before so I’m not sure how I’d get the same effect using forces…

//right before the loop (note I tried to put this inside the loop too, and no difference)
if (gameObject.GetComponent<Rigidbody>())
//inside the loop
var direction = ActiveNode.transform.position - transform.position;
                var rotation = Quaternion.LookRotation(direction);

                var tempRotN = _rotationNoise;
                var tempSpeedN = _movementNoise;

                if (_rotationNoise <= 0) tempRotN = 0.05f;
                if (_movementNoise <= 0) tempSpeedN = 0.05f;

                var finalTurnSpeed= _turnSpeed + UnityEngine.Random.Range(0.001f, tempRotN);
                var finalSpeed = _speed + UnityEngine.Random.Range(0.001f, tempSpeedN);

                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, finalTurnSpeed * Time.deltaTime);
                transform.Translate(new Vector3(0, 0, finalSpeed * Time.deltaTime));
//right outside the loop (when it's ended)
if (gameObject.GetComponent<Rigidbody>())
				gameObject.GetComponent<Rigidbody>().isKinematic = false;

Nevermind about the kinematic issue. Thanks to a guy in the unity forums for making me double check my code. There was a check which depended on a upper level variable, and I didn’t notice I wasn’t reseting it. Anyway, thanks :slight_smile:

…Still, if anyone can advise me on how to make this same effect using forces, that’ll be swell, heh.