Posts

Showing posts from September, 2014

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

A Healthy Solution to Pivot Problem - Unity 3D

Image
I will today share a solution that i found more convenient and functional about Pivot ! So lets do it.  When we talk about 3D model ! Every character or an object have a pivot point.  That is very important that pivot should be in the center of that object. If it's not in the center we have to face many problem regarding this. Keeping the model aside. If you have imported a model in unity you have to work with it independent of the graphics and designs. If your logic is dependent on models then you have to face many problems.  Lets come across with a common problem that we face in unity is pivot problem. Models that we import sometimes have pivot disturbed position. And it's difficult to work with! Now if we have to rotate an object  it will rotate around the pivot. The object will change not only its current axis but also position. Now that frustrating why the object changes it's position. It's satisfactory if there is nothing to do in the game scene ! because w

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

Image
In This Blog We Will Discuss Some more Keywords. Input.GetAxis : In this picture a chunk of code is placed. You will see that Input.GetAxis("Vertical") returns a value. The value is from 1 to -1. When there is no key pressed the value is zero. Actually it returns the value of virtual axis. If we use Debug.log then the console will show some value on clicking the right or left button that will be constantly changing.  Other thing is that Vertical is pointing towards the built in inputs. As you can see in the picture above that the vertical have some columns in it. Where the vertical have positive and negative button which give positive or negative float value on event pressed. Whereas if we don't want to use these inputs . We can write code instead of writing Vertical or horizontal in the brackets of input.getaxis. We can write it as Input.GetAxis(keycode.space); .  Here the space key is assigined and it will return some value. OnMouseDown() : OnMouse