Posts

Showing posts from 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

Look at , lerp , Destroy gameObject - Unity

Image
Look at   Lets just discuss about the code and look at use. I have used the look at function to change the direction of the camera while the game is playing. As i have created a character. Which falls on the ground. Now In order to show the ball falling look at function is used that shows while playing. Now here the script is added where in the target section i have added a moving cube. That the camera demands the object on which it have to focus. Now lets see the code that simple to understand.  Now here the Transform object reference is given which demands a particular object. That is given be given in the picture above shown.  Lerp  Vector 3.lerp is used to change the position of an object between two points. In this section i have added the lerp attribute to the camera. So the camera will move between two points. Lets see the code things will get more clear. Here on the first line a Vector3 is declared. Where in the awake transform position will assign th

How to move an object in Unity 3D

Image
How to move an Object Backward and Forward in Unity 3D !  First of all lets discuss some of the key words that are necessary to understand.  Vector 3: Its a representation of 3 vector points. You have listened the x ,y and z axis. So here vector 3 takes all the 3 values. The points in the back and forward will be (0,0,-1), (0,0,1) respectively. Time.deltatime:  Function is used to make the game rate independent. If you multiply the variable with time.delta time it means you are saying that i want to move the object 10 meter per second. Basically you use delta time to update your movements. Transform.translate:   Transform.translate is basically used for the movement of the object as it takes the 3 axis value to move the object.  It's related to the distance the object will move. Now lets see some practical example to make a object working. We take a cube for the example purpose. Then add script to it. Now lets see the played situation. As my object is mo

Vector Math - Unity

Image
Vector Math  Addition:  As you that the vector addition is defined by the combined effect of two or more than two vectors. When the tail of one vector is added to the head of other vector addition is made. This can be defined by a parallelogram.Actually joining two vectors result into a new vector. Subtraction:  Vector subtraction is performed to get the direction and distance from one object to another. The addition and subtraction of vectors is similar as the subtraction of vector will have negative negative magnitude that means opposite in direction. As in subtraction head to tail rule is also used. Dot Product : The multiplication of two vectors will result in a scalar quantity. Where Theta is the angle is multiplication of the two vectors is 0 than its perpendicular. In unity we use Mathf.Cos. Which perform equal-ant function. Cross Product: The result is perpendicular to the two vectors. The "Left hand rule" can be used to remember the d

GameObject - Unity

Image
  Game Object  Game object in unity is basically a container that requires properties to make them a character. Suppose a room the type of things you will place will be the type and use of the room. Likewise, components added to the game object will define the type of the game object. Game objects have transform component attached to it that can't be removed. GameObject.renderer  Game object renderer  is use to make character appear on the screen. It can also be used to change the color of the object. Having further different properties. To change the color of the Object  Taking a small example to learn, take a cube in the scene and add a script in the cube through add component. Then add the code given below. void Update () { if(Input.GetKeyDown(KeyCode.R)) { gameObject.renderer.material.color=Color.red; } } To make Object Transparent  GameObject g; g.renderer.material.color.a = 0.5f; g.renderer.material.color.a = 1.0f; To make an Object visib

Navigating data from one page to other page

Image
This articles is about navigation from one page to other and sending data from one page to another.  There is very simple method for the navigation. First i have created a button on a page and under that code a navigation code is written that on run time pass focus from one page to other. That page is added in the solution explorer. Apart from that a class is made where the properties methods are written.  When the information is passed from the button within the navigation code in the form of string values they are assigned to the variables in the class and that will be there until the application is closed.  Here i have added a button that will navigate from one page to other. This is the code that is written for navigation. you can see that after the question mark sign you can see the text values that will further be assigned.  Here is another sample class data. Where the variable are assigned properties. That will be used in the code below.  This

Weather application with the help of Json parsing

Image
Today, I will create a weather application using Json.   Today,  we will see an application that will give you the temperature of a country. You might have listen about the longitude and latitude. The lon. and lat. will help us to get the location of the country. The question is what's the logic used in application. The answer is that i have created a button and the textblock in the mainpage.xaml and on the click event. A code has been generated that sync the json code from the website and convert the data ! After that the temperature is displayed. In this process we have installed Newtonsoft json package in visual studio. And a class is made that is the result of json code extraction.  Now lets see how the weather application will work.  Lets first install the newton soft Json Package. In the tool box go to the library package Manager then package manger console and click it. Below there write Install Package Newtonsoft Json after writing this click enter. The package will in

Creating web form in Asp.net

Image
How to create web form in asp.net ! Creating web form is very easy. First i will create asp.net application. Them add web form in the solution explorer. Than click the design button to see the output of the source code. Then from table insert table and add desired number of rows and columns. Then add labels in the rows. After that add text-boxes to get data. Add a button write code to show all the retrieved data on label. Now i will show how to do this. I hope a brief explanation made it easy to understand !       First create a web application. Then after that add a web form in the solution explorer. For that click the application name              click Add--> Add new item --> Web form.  Click the design button in the below bar. Click the Tables button-->add tables. Then add desired rows and columns. But if you are following me than i have added 5 rows and 2 columns. Here i have edited the label that is imported from the tool box.                  

Animation (Flying kite) in blend

Image
Today i will write some words about the animation making in blend.  Let me first tell you the structure what actually it is.In an application if you want to make some animation. It can be possible through blend. Like if you want to bounce a ball, fly a mosquito and many other things like that. I 'm going to make a kite using an eclipse and two rectangles. By joining them together into a grid. Adding behaviors and events. After working on animation my application looked something like this. Where the kite moves. I hope you will find it great. First create a xaml application in blend. Now take a rectangle from the left side bar. and add it. Then rotate it to give an illusion of thread. Copy an another triangle and paste it above that triangle.  Now take an eclipse from the right bar and add it here. you can change the color from the side bar properties too so that i will look good. rotate the square and give it the illusion of a kite. Now press shift

Convert HTML website into ASP.NET

Image
Today, i 'm going to discuss about the conversion of html website to asp.net ! First, lets just discuss the little about the asp.net. It's a developing framework for web based languages. Like HTML,Css, JavaScript and server scripting languages. It was introduced by Microsoft in 1998. Now after open the visual studio first create a new project. Now click web-> visual studio 2012 and create asp.net empty application. After that in properties section click the name of the page and after right clicking it add new item then add web form master page as shown in the picture. click add. A page will open as shown below. Now the task is that we have to make master page where we have to place the header and footer of the page. Now we have to add the html template or theme of website that is made in asp.net. and have to include them in the project. As the header and footer will appear in all pages so a page has been made where the code is static and will appear i