AddTorque from position of mouse/touch?

Hey there,

I like to do a game, which you have an object that is jumping, depending on which place you clicked at it. Now I already have this function:

                    Vector3 Center = this.transform.position;
                    Vector3 forward = Vector3.up;

                    Vector3 clickedPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    Vector3 forceDirection = (Center - clickedPosition).normalized;

but it doesn’t look so good without rotating from the direction you clicked. That’s the problem. I need help to addTorque that rotates at the opposite direction you clicked. Both left and right (z-axis). I hope everybody will understand…

Sounds like you need to be working with RelativeTorque or RelativeForce.

EDIT: My bad, it’s actually Unity - Scripting API: Rigidbody.AddForceAtPosition that’s going to be helping you… I’ll see if I can’t whip up a script for you.