I have some obstacle like stick that is upright. It's move by velocity vector in rigibody2d (-4,0). And I have a hero which always stay in center of game screen. When hero collides with a stick, I want that obstacle flew away with some rotation, depending on the point of collision (like the laws of physics, if the collision point near the edges, then more torque).
But, AddTorque on rigibody2D doesn't work, although AddForce works fine.
There is code of collision
void OnCollisionEnter2D(Collision2D other)
{
if (other.collider.tag == "Block")
{
if (InvBonusEnabled) {
other.collider.isTrigger = true;
other.rigidbody.isKinematic = false;
other.rigidbody.AddTorque(100); //simple test doesn't work
other.rigidbody.AddForce(new Vector2(200, 50));
//
}
}
}
I can't attach screen with prefab rigibody2D and collider2D settings (reputation 10 required on this stackoverflow)
Rigibody2D
Mass: 1
Linear Drag: 0
Angular Drag: 0.05
Gravity Scale: 1
IsKinematic: True
All Freeze Postion and Rotation are false
Collider2D
IsTrigger: false
What am I doing wrong?
Your torque may be too low of a number. Try upping it to the thousands or higher even.
Try also increasing the rigidbody.maxAngularVelocity
thats worked for me before
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With