I'm trying to lift the front wheel of my bike, and I got it, applying this:
GetComponent.<Rigidbody>().AddForceAtPosition(Vector3(0,300,0), Vector3(GetComponent.<Rigidbody>().position.x, (GetComponent.<Rigidbody>().position.y)+5,(GetComponent.<Rigidbody>().position.z)+10)); Works perfect, but only when the bike is on start position, when I turn it to different position the force is applied on incorrect axis.
How I can do this applying the force on local object and ALWAYS on the same position and up direction??
Thank you.
-- EDIT --
As usual, problem solved, thank you to this amazing site and amazing people. Here is the working code:
public var force : Vector3; public var forcePosition : Transform; private var rbody : Rigidbody; (on Start function) rbody = GetComponent<Rigidbody>(); (on update function) if(Input.GetKey(KeyCode.F) && Input.GetKey(KeyCode.UpArrow) && curGear >0 && WheelR.isGrounded) { var setPositionForce = Vector3(forcePosition.position.x,forcePosition.position.y, forcePosition.position.z); rbody.AddForceAtPosition (force, setPositionForce); } Well, I added on if the "F" key just for test and is necessary to move the wheel and to move the wheel first gear is nedded, and minium, the rear wheel is on floor. The bike is stable when the wheel is going up and works perfectly on all directions.