Transform.LocalEulerAngle, how to measure speed of rotational body- Unity 3D

You have to know the difference when you switch the languages ! 

When you start writing to code for your game you either start with the C# or java-script or any other available language. I would like to share a small difference between these two languages syntax when you  are required or like to deal with both languages.

I like to code in C# but some how have to deal with java-script. Where is found some thing about a scripting API Transform.LocalEulerAngle. First lets see what these API do. Lets discuss some other Api too.

Transform.LocalEulerAngle :

When you have to rotate something you use this api it rotate an object around an axis.  When you write this in Javascript. Then transform.LocalEulerAngle.y= 10f. But you can n't write the same for C#. As it's a vector3 in C#. Whereas Vector3 is a struct, whereas Eulerangle will return a copy. By assigning the value 10 means that you are making a temporary change in the copy. That does not happen.  So in C# you can write like this Transform.LocalEulerAngle=new Vector3(0f,10f,0f).



How to measure speed with wheel Collider :

Inorder to measure the speed of a car or some rotaional body. We can do that with the Wheelcollider
the formula includes the the radius of the rotational body plus the rotation per minute and pi.

  var speed= 2 * 22/7 *cirularbody.radius * circularbody.rpm;

Here the circular body is the empty gameobject in which the wheel collider is added.

Comments

Popular posts from this blog

How to move an object in Unity 3D

Input.Getaxis, OnMouseDown, GetComponent< > - Unity Scripts

Vector Math - Unity