Rigidbody.AddForceAtPosition & functions

My first question has to do with function Update () and function FixedUpdate (). According to Unity docs, function FixedUpdate should be used when applying physics to rigidbodies. I have code that involves using rigidbody physics on a key press but it also includes other things such as changing values within the same if statement. Update is called before every frame is rendered. These values may change every frame. Can FixedUpdate be used for changing values every frame?

Also, what would be the result of putting rigidbody physics in Update?

My second questions about rigidbody.AddForceAtPosition. For adding a force on RaycastHit, I used this code:

hit.rigidbody.AddForceAtPosition (hit.transform.position, transform.position * hitForce);

Am I doing this right?

First of all you should have split questions.
But I’ll try to answer both.

All physics calls you must do in FixedUpdate because that’s where Unity recalculates everything physics related. You might not notice anything if calling physics methods in Update but usually behavior wil be wrong. If you see odd behavior check whether you have physics code in FixedUpdate.

And yes, you can set other parameters in FixedUpdate. But it runs with slower framerate than Update so parameters you update in FixedUpdate will not be seen immediately and their discreet values will span across several frames.

The second part.
addForceAtPosition has the following signature: function AddForceAtPosition (force : Vector3, position : Vector3, mode : ForceMode = ForceMode.Force) : void. So you need to call it this way:

hit.rigidbody.AddForceAtPosition(force, hit.point);

Where force is the force you want to apply.

UPDATE

To execute specific code in Update and do something in FixedUpdate you could use a coroutine like this:

void Update() {
  // your code
  StartCoroutine(applyForce(hit, force));
}

IEnumerator applyForce(RaycastHit hit, Vector3 force) {
  yield return new WaitForFixedUpdate();
  hit.rigidbody.AddForceAtPosition(force, hit.point);
}