Can I set the torque/angularVelocity and rotation directly?

Hi,
I’m having some serious trouble. Is there anyway I can set the:
rigidbody.transform.rotation.eulerAngles.z
directly? I want it set to 0.

And is there someway I can set the:
rigidbody.angularVelocity.z
directly? I want it aswell set to 0.

I’d appreciate the help.
Thanks in Advance!

Erhm… maybe try assigning 0 to those values?

I can’t. It seems I can only read them. Visual Studio complains about them not being variables.

You’re using C# or Boo, right? You have to assign the whole vector/quaternion at once with these languages - you can’t assign the individual components. This is because the values aren’t variables as such, but properties.

To set the Euler angles of a rotation, you can use Quaternion.Euler. For the angular velocity vector, you just need to assign the whole vector at once.

Yeah, I’m using C#.
So that’s why. So you can set them directly using JS?

Well, I’ll give the Quaternion.Euler a go ASAP. Thank you very much!

From the user’s perspective, yes, although it’s doing the work for you behind the scenes that you would do manually in C#, so technically no.

–Eric

I’m starting to regret my choice of trying to work with and learn C# isntead of JS, since it always seems like the solution is easier with JS.

Oh well…

Thanks!

Nah, it’s worth knowing both. JS is indeed usually more convenient and I use it 99% of the time, but it’s useful to understand what’s actually happening.

–Eric

Don’t regret learning C#… it’s a lovely language. Not only that, it’s used extensively in industry, so any experience you gain within the world of Unity, will stand you in good stead.

Matt.