Reputation: 78
like in the picture I want to add a force to a parent object in such a way that it will rotate 90 degrees while moving right and up. I stored the position below the object to help the rotating motion but I dont know any way to put into code.
Upvotes: 2
Views: 921
Reputation: 90683
I think what you are looking for is AddForceAtPosition
Applies force at position. As a result this will apply a torque and force on the object.
GetComponent<RigidBody>().AddForceAtPosition(Vector3.right, child.transform.position);
Upvotes: 1