ZozeR
ZozeR

Reputation: 78

Add force and rotate object at the same time

object layout and force way

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

Answers (1)

derHugo
derHugo

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

Related Questions