Skip to main content


Showing posts from January, 2014

How to do a popup animation using Unity GUI

Today i am posting on how to do a popup animation using Unity GUI. I was trying to write my own logic and i came up with this. Press GUI button S to start the popup Animation and R to reset the GUI Button.

here is a WebPlayer link :

using UnityEngine; using System.Collections;
publicclassPopupAnimation : MonoBehaviour { privatefloat  xpos; privatefloat  ypos; privatefloat   xlength; privatefloat  ylength; privatefloat   rate; publicfloat   sizeOfGUI = 200; void Start () {        xlength = 0;        ylength = 0; }
void OnGUI() { GUI.Box(newRect(Screen.width/2-xpos,Screen.height/2-ypos,xlength,ylength),""); if(GUI.Button(newRect(Screen.width/2-50,Screen.height-50,50,50),"S"))        {                  StartCoroutine("BubbleAnimation");        } if(GUI.Button(newRect(Screen.width/2+10,Screen.height-50,50,50),"R"))        {                  ResetValues();        } }
IEnumerator BubbleAnimation() { int    count       = newint   (); float  lengthLocal = newflo…

Projectile Motion in Unity

Hi Guys, Today i wanna post a blog on Projectile motion in Unity3D. I was very much interested in projectile motion for a long time, but finally i got time to try my hands on it and results were pretty good. Though i failed few time to make the equation work but at the end it was fun.

Here is a web build,

I am using only 2 script, first one is just for GUI, and Second one is for pojectile motion.

This script is for GUI

using UnityEngine; using System.Collections;
publicclass ProjectileTest1 : MonoBehaviour { publicfloat initialV = 20; publicfloat hSliderAngleValue = 0.0f; publicfloat hSliderPowerValue = 0.0f; publicGameObject bomb;
void Update () {         transform.rotation = Quaternion.Euler(0,0,hSliderAngleValue);         if(Input.GetKeyDown(KeyCode.R))         {                 Application.LoadLevel(0);         } } void OnGUI() { GUI.Box(newRect(Screen.width-120,Screen.height-240,100,50),"Angle");         hSliderAngleValue = GUI.HorizontalSlider (newRect (Screen.wi…