Applying force at contact.point

Hello everyone. I am trying to apply relative force to a rigidbody (cylinder) at its contact point with the ground. The direction of the force applied has to change according to the surface which the cylinder is touching. The pictures show how the direction of the force, applied from rigidbody’s contact point(s), should change. Orange sphere is a contact point, yellow arrow - force that should by applied to the cylinder by the script, blue triangle on a cylinder just shows that it is not rotating when clearing the obstacle.

34808-3dpvz2.png
34809-3dpvz4.png

Current working code:

function OnCollisionStay (collision : Collision) {
	
    for (var contact : ContactPoint in collision.contacts) {
			
        contacts = collision.contacts.Length;

        if(Input.GetKey(KeyCode.W)){
			
        var dir : Vector3;
        dir = (transform.position - contact.point);
        rigidbody.rigidbody.AddForceAtPosition(Vector3.Cross(transform.right, dir).normalized * (Power / collision.contacts.Length) * Time.deltaTime, contact.point);
			
        }
		
    }

}

In this code, made using the suggestion of Habitablaba, I have created a vector (dir) from the center of the cylinder towards the contact point, crossed it with transform.right to create a direction offset and normalized it. Variable “Power” is a float, it is divided by the number of contacts so that the total force does not increase when the rigidbody has more than one contact with the surface.

Take the collision point and add force forward regarding from center in 90 degree angle.

Still figuring out what you even want.

If you are after the direction of the vector shown in the pic then you need to take the cross product of the contact point minus the centre point and the vector going into the page. I’d suggest normalising the result. This assumes you are working in 2D