how can i fix this???
The argument needs to be a Vector3
. You first need to determine the axis (or axes) you want to apply the torque to, and then provide a Vector3
with that amount.
Let’s say you want the torque to be applied along the x-axis (Vector3.right
). Then you’d multiply Vector3.right
with the torqueAmount
, so rb2d.AddTorque(Vector3.right * torqueAmount)
.
Vector3.right
is the same as Vector3(1, 0, 0)
and multiplying Vector3.right * torqueAmount
is the same as new Vector3(1 * torqueAmount, 0 * torqueAmount, 0 * torqueAmount)
OK, this is my bad. You actually had stuff wrong in the first screenshot that I didn’t see: You had a Rigidbody
instead of a Rigidbody2D
. I see you have fixed it now. The original error was referencing a Rigidbody
not Rigidbody2D
. With a RigidBody2D
you can actually just give it the torqueAmount
but you also need to give it a ForceMode
.
Here’s the documentation:
oh lol i see thankyou for the help
This can get you pretty easily from time to time. Always check if your colliders and rigid bodies say 2d at the end when working in 2d. its such an easy mistake to make, i have probably done it half a dozen times this last year.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.