Made a very simple Gravity simulation between 2 bodies.
I just wanted to try out Unity 5. It feels really good to work with a full version doesn't it!
Was trying out attracting two objects, then googled here and there and found Force is inversely proportion to distance squared etc. Just put these into a scene and started playing around.
Then it suddenly hit me how slingshot and orbiting works. WTF.. so many years in school, never understood a damn thing!
Btw, Unity has WebGL deployment now - publishes a 30mb js file x_x
Showing posts with label Unity. Show all posts
Showing posts with label Unity. Show all posts
Mecanim Tryout
Let's make Unity's Ethan shake hand with a very very hot invisible chick.
Press 'X' to shake hands
Very simple state machine
Idle to Shake Transition
Shake To Idle Transition
Flowchart-
Idle keeps looping
When "Shake" is set >> transition to Shake
Stay there until exit-time has occurred and Shake is set to false (It should be play once)
So we do need to write some code for this, Mecanim can't variables and stuff I think (not sure).
The trick for using "Boolean" trigger in Mecanim is -
Check if we are in proper state.
Set Flag
Next loop - Unset flag
Animation re-targeting is cool and all.. but I'm not so impressed with the design / architecture yet. Looks to me like it's gonna end up being a big pile of mess with lot of patch-works everywhere. Hope I'm wrong for my own sake..
Very simple state machine
Idle to Shake Transition
Shake To Idle Transition
Flowchart-
Idle keeps looping
When "Shake" is set >> transition to Shake
Stay there until exit-time has occurred and Shake is set to false (It should be play once)
So we do need to write some code for this, Mecanim can't variables and stuff I think (not sure).
The trick for using "Boolean" trigger in Mecanim is -
Check if we are in proper state.
Set Flag
Next loop - Unset flag
Animation re-targeting is cool and all.. but I'm not so impressed with the design / architecture yet. Looks to me like it's gonna end up being a big pile of mess with lot of patch-works everywhere. Hope I'm wrong for my own sake..
A long time ago
A long time ago, I was a student. I was in my 12th (means final year of schooling, next up engineering). I had an exam the next day. Like always, I thought "let me study later, the day is still young and I have all night long to prepare."
So I started watching some highlights of a soccer game I had missed. Then came Dragonball Z. Then came something else, something else and so did the evening. It was sunset. Suddenly lights went out. But why? My dad had got an inverter installed an year back, I had UPS backup? It was then I realized there was a major power cut from morning and I had used up most of the battery.
WTF! My exams.. So while I was still like "Meh.." my parents freaked out, sometimes power never used to come back till next morning those days (actually sometimes even now). So we decided, we'll use the power judiciously.
So when I was studying, other than the one light in my room everything else was switched off. Then when my mom went to cook, only the kitchen light was on - and I waited. So using 1 light the whole night long, managed to pull it off without tripping the inverter.
You are probably thinking why I wrote this now?
Well... Unity just released a new version and you can have 1 dynamic light in the free version ^_^
Just saying... 1 light can make a big difference.
Also, a contest [See what I did there? O_o]
So I started watching some highlights of a soccer game I had missed. Then came Dragonball Z. Then came something else, something else and so did the evening. It was sunset. Suddenly lights went out. But why? My dad had got an inverter installed an year back, I had UPS backup? It was then I realized there was a major power cut from morning and I had used up most of the battery.
WTF! My exams.. So while I was still like "Meh.." my parents freaked out, sometimes power never used to come back till next morning those days (actually sometimes even now). So we decided, we'll use the power judiciously.
So when I was studying, other than the one light in my room everything else was switched off. Then when my mom went to cook, only the kitchen light was on - and I waited. So using 1 light the whole night long, managed to pull it off without tripping the inverter.
You are probably thinking why I wrote this now?
Well... Unity just released a new version and you can have 1 dynamic light in the free version ^_^
Just saying... 1 light can make a big difference.
Also, a contest [See what I did there? O_o]
Teleport Rush - On Kongregate
My 1st Game on Kongregate!
Well, I've kinda reached coder's block. Teleport Rush didn't seem to be progressing a lot these days, so I decided to see the reception on Kongregate.
You can check it out here.
Screenshots
Well, I've kinda reached coder's block. Teleport Rush didn't seem to be progressing a lot these days, so I decided to see the reception on Kongregate.
You can check it out here.
Screenshots
It's frakking tiring to come home after 9 hrs of work and 3 hrs of travel and do some game dev... sucks... wish there was someone to design tracks & environment, and I could just code... Also wish that someone was a cute chick X_x
Teleport Rush - WIP
Something I've been developing in my free time. It mutated from Desolate Racers..
I was trying this out when Unity announced their Flash contest. So I submitted a proto for the contest. Flash export is still in Beta, but it's pretty good.
Here's link to Flash screenshots
Link to playable flash version (no sounds, lights and I couldn't put any cool shaders)
I'm actually amazed at the complexity of Unity to Flash publishing - it converts all C# code (.NET / Mono framework) to Actionscript 3. What's more frakking mazin? Unity engine itself occupied under 2.5MB for all this!! (all this means - rendering, physics, collision, particle-systems, audio and more)
I was trying this out when Unity announced their Flash contest. So I submitted a proto for the contest. Flash export is still in Beta, but it's pretty good.
Here's link to Flash screenshots
Link to playable flash version (no sounds, lights and I couldn't put any cool shaders)
I'm actually amazed at the complexity of Unity to Flash publishing - it converts all C# code (.NET / Mono framework) to Actionscript 3. What's more frakking mazin? Unity engine itself occupied under 2.5MB for all this!! (all this means - rendering, physics, collision, particle-systems, audio and more)
Compass in Unity3D
Tutorial about creating a Compass in Unity3D.
Level: Basic
Topics: GUI, Texture2D, Euler Angles
Final Result: Something like this
What you need:
Background texture of the compass like this -
Compass Bubble texture - Google for some bubble icons, I got mine from here.
To the code minions....
Class members:
//For holding the compass textures
Texture2D bg;
Texture2D bubble;
//"North" in the game
//0 for + Z Axis, 90 for + X Axis, etc
float north;
//Where the compass needs to be placed
Vector2 center;
//Size in pixels about how big the compass should be
Vector2 compassSize;
Vector2 bubbleSize;
//Where the compass bubble needs to be inside the compass
float radius;
Constructor:
//Set the placement of compass from size and center
compassRect = new Rect(
center.x - compassSize.x / 2,
center.y - compassSize.y / 2,
compassSize.x,
compassSize.y);
Update:
// Note -90
float rot = (-90 + this.transform.eulerAngles.y - north)* Mathf.Deg2Rad;
// Bubble position
x = radius * Mathf.Cos(rot);
y = radius * Mathf.Sin(rot);
OnGUI:
// Draw the background
GUI.DrawTexture(compassRect, bg);
// Draw bubble
GUI.DrawTexture(new Rect( center.x + x - bubbleSize.x / 2, // Compensate for texture
center.y + y - bubbleSize.y/2, // width of bubble
bubbleSize.x,
bubbleSize.y),
bubble);
Notes:
Make sure width and height of compass texture is same (or modify the logic to compensate for it)
How to test:
Import Character controller package
Add FPS controller to your scene
Add this compass componenet to it
Set the "north" angle and others params.... Run.. Done.
Download the complete code from here.
Procedural Track Generation in Unity3D
This post is basically how to generate a procedural/dynamic road or a track at run time in Unity3D.
Work-flow:
Prerequisite: Check out this link
Final Result:
This mesh is actually an extrusion of the following 2D surface -
In 3D, this is how it looks -
Explanation of terms -
Block - 1,2,..n - The entire track is built of a sequence of building blocks. This is the repeating entity in the track
Points - P1, P2.. Pn - Points that define the track (input for this generator)
Sequence - S1, S2,.. Sn - The track can be thought of these 8 sequences of vertices (4 are shown above). Each sequence originates from the corners of the flat 2D surface above
Lets call this Track-Generator, hmmm.. let's see.. GUS ( I'm sure AlterVik would have given it a better name... eviiiiiiiil).
Gus needs an Array of Vector3, which is the list of Points described above. GUS generates the track along these points. This means that when GUS gets hungry, you create a spline (line) in your fav 3D editor and export the points and feed it to GUS.
How GUS works -
First of all GUS assumes this is not a loop (To loop, GUS expects you to mutate it and create GEORGE, GEORGE LOOGUS). Secondly, GUS expects at least 2 points. Anyway...
1. Gus calculates the number of blocks required as ( # of Points -1 ) and calls it "n" [ n = #Points -1 ]
2. Gus knows there are 8 Sequences of vertices in track as calls it "S"[ S = 8]
3. Gus then identifies number of vertices required as 18 + (n-1) x 8
[ 16 for 1st block, +8 for each after ]
Now GUS loops S=8 times (for each Sequence required) -
For this Sequence
GUS finds out offset [width (w) and height (h)] of the sequence from the center
For each Block
GUS finds out in which direction the track is moving [ P(n+1) - P(n)]
GUS finds out Left Direction from this [ See Note at the end ]
GUS adds point [ P + Left * w + Up * h]
Now it's time for GUS to identify the Triangles...
GUS knows there are n x 16 Tris, hence n x 16 x 3 points to define all the Tris.
Like before, GUS loops S=8 times (for each Sequence required) -
For this Sequence
For each Block
Green Tri's points - (i)th and (i+1)th vertex from Sequence S, (i)th from S + 1
Red Tri's points - (i+1)th vertex from Sequence S, (i)th and (i+1)th from S + 1
That's it. I haven't explained the complete workflow as given in 1st fig, you can refer the code below and this is in no way optimized and bug free... so basically WTF License.
Notes:
1. While calculating the direction in which the Track is being generated, GUS assumes that the Road is not banked. Reason being, GUS only has a line as direction, there can be infinite "Up" vectors. Hence, GUS assumes "Up" to be global "Up" axis. Based on this, GUS does Cross-product of "Up" and "Forward" to get "Left".
To have banking, points given to GUS should also have associated Left or Up direction data. In short, GUS should be mutated into BOGUS - to calculate direction based on BOth these data.
2. GUS no like UV mapping for now.
Code
Save this link.
Add the script to a game object and set the width and height parameters.
If it helped you in some way, leave a comment so that I know someone out there is actually reading all this x_X
Work-flow:
Prerequisite: Check out this link
Final Result:
This mesh is actually an extrusion of the following 2D surface -
In 3D, this is how it looks -
Explanation of terms -
Block - 1,2,..n - The entire track is built of a sequence of building blocks. This is the repeating entity in the track
Points - P1, P2.. Pn - Points that define the track (input for this generator)
Sequence - S1, S2,.. Sn - The track can be thought of these 8 sequences of vertices (4 are shown above). Each sequence originates from the corners of the flat 2D surface above
Lets call this Track-Generator, hmmm.. let's see.. GUS ( I'm sure AlterVik would have given it a better name... eviiiiiiiil).
Gus needs an Array of Vector3, which is the list of Points described above. GUS generates the track along these points. This means that when GUS gets hungry, you create a spline (line) in your fav 3D editor and export the points and feed it to GUS.
How GUS works -
First of all GUS assumes this is not a loop (To loop, GUS expects you to mutate it and create GEORGE, GEORGE LOOGUS). Secondly, GUS expects at least 2 points. Anyway...
1. Gus calculates the number of blocks required as ( # of Points -1 ) and calls it "n" [ n = #Points -1 ]
2. Gus knows there are 8 Sequences of vertices in track as calls it "S"[ S = 8]
3. Gus then identifies number of vertices required as 18 + (n-1) x 8
[ 16 for 1st block, +8 for each after ]
Now GUS loops S=8 times (for each Sequence required) -
For this Sequence
GUS finds out offset [width (w) and height (h)] of the sequence from the center
For each Block
GUS finds out in which direction the track is moving [ P(n+1) - P(n)]
GUS finds out Left Direction from this [ See Note at the end ]
GUS adds point [ P + Left * w + Up * h]
Now it's time for GUS to identify the Triangles...
GUS knows there are n x 16 Tris, hence n x 16 x 3 points to define all the Tris.
Like before, GUS loops S=8 times (for each Sequence required) -
For this Sequence
For each Block
Green Tri's points - (i)th and (i+1)th vertex from Sequence S, (i)th from S + 1
Red Tri's points - (i+1)th vertex from Sequence S, (i)th and (i+1)th from S + 1
That's it. I haven't explained the complete workflow as given in 1st fig, you can refer the code below and this is in no way optimized and bug free... so basically WTF License.
Notes:
1. While calculating the direction in which the Track is being generated, GUS assumes that the Road is not banked. Reason being, GUS only has a line as direction, there can be infinite "Up" vectors. Hence, GUS assumes "Up" to be global "Up" axis. Based on this, GUS does Cross-product of "Up" and "Forward" to get "Left".
To have banking, points given to GUS should also have associated Left or Up direction data. In short, GUS should be mutated into BOGUS - to calculate direction based on BOth these data.
2. GUS no like UV mapping for now.
Code
Save this link.
Add the script to a game object and set the width and height parameters.
If it helped you in some way, leave a comment so that I know someone out there is actually reading all this x_X
Yowza year for the Gaming Industry
Everything's going web-based, things I probably never imagined.
When I started with Unity3D I thought, well here's a platform for both Windows and Web. All we need to do is develop for one and the other fits right in. Last year, to develop 3d on the web, there weren't much options - it was either Unity or Flash (software based rendering of course)
Times have changed... drastically. Or was I not paying attention? x_x
As of now, these are the following ways to publish 3D games on the web -
Unity 3D
Flash 11 (Molehill as of now)
Silverlight 5
WebGL
Lets take out WebGL, cos I feel it's not mature enough (read browser compatibility)
As of 2010, whatever 3D you'd do on the web would leave out an important target - Linux.
Adobe, being the target of sick-mindless-cribbing -whoa-HTML5-will-kill-it people has proved once again what it is to be a visionary.
Talk about development options for Flash 11 - Unity3D, Epic's UDK and Away 3D.
[ I was wondering why Unity came up with this Flash export option. They expected Epic to? ]
Silverlight 5 RC also means you can have your XNA games on the Web! ( I really never imagined this day would come)
Looks like "Browser" is indeed becoming a Platform. When Google said this, it sounded ridiculous to me. Well now I'm a little.. never mind.. not gonna admit it. Well, Is Google Chrome headed in the right direction then? I don't know actually.. but I have this zoinks-scoob-something's-fishy feeling that it's gonna revolutionize gaming platform.
My predictions -
1. Chrome is gonna change the equation for WebGL ( it's the only thing that can actually be 100% platform agnostic).
2. Chrome and Android are gonna leverage the same tech for making web = mobile equation true
Can't wait for Google to release their Game Engine (hope it's not in Go.. fingers crossed)
When I started with Unity3D I thought, well here's a platform for both Windows and Web. All we need to do is develop for one and the other fits right in. Last year, to develop 3d on the web, there weren't much options - it was either Unity or Flash (software based rendering of course)
Times have changed... drastically. Or was I not paying attention? x_x
As of now, these are the following ways to publish 3D games on the web -
Unity 3D
Flash 11 (Molehill as of now)
Silverlight 5
WebGL
Lets take out WebGL, cos I feel it's not mature enough (read browser compatibility)
As of 2010, whatever 3D you'd do on the web would leave out an important target - Linux.
Adobe, being the target of sick-mindless-cribbing -whoa-HTML5-will-kill-it people has proved once again what it is to be a visionary.
Talk about development options for Flash 11 - Unity3D, Epic's UDK and Away 3D.
[ I was wondering why Unity came up with this Flash export option. They expected Epic to? ]
Silverlight 5 RC also means you can have your XNA games on the Web! ( I really never imagined this day would come)
Looks like "Browser" is indeed becoming a Platform. When Google said this, it sounded ridiculous to me. Well now I'm a little.. never mind.. not gonna admit it. Well, Is Google Chrome headed in the right direction then? I don't know actually.. but I have this zoinks-scoob-something's-fishy feeling that it's gonna revolutionize gaming platform.
My predictions -
1. Chrome is gonna change the equation for WebGL ( it's the only thing that can actually be 100% platform agnostic).
2. Chrome and Android are gonna leverage the same tech for making web = mobile equation true
Can't wait for Google to release their Game Engine (hope it's not in Go.. fingers crossed)
Air Hockey in Unity3D
Simple prototype I made in Unity3D. (Requires Unity web-player plugin)
Things to ponder -
It's a pain in the brain (O_o) to configure the Physics engine to work for simple things like this, that too when scaled to real world.
First i had to setup a few parameters to tell Physx to consider collision at very small dimensions
Then I had to tell it to use "Bouncy" material
Then I had to tell it to confine rotation and stuff so that Puck doesn't fly-off.
Things to ponder -
It's a pain in the brain (O_o) to configure the Physics engine to work for simple things like this, that too when scaled to real world.
First i had to setup a few parameters to tell Physx to consider collision at very small dimensions
Then I had to tell it to use "Bouncy" material
Then I had to tell it to confine rotation and stuff so that Puck doesn't fly-off.
I still couldn't get the desired effect, and like icing on cake - there is no "Cylinder" collider in Unity, nor a 2D-Circle thingy. So eventually, i was frustrated with all this, did my very-simple-stupid-flawed Circle-circle collision x_x
This proto has NO rigid bodies at all, the physics engine is probably like "Dude.. I'm bored >.<"
Lessons learnt -
To make small games like these, it's probably a good idea to scale everything up
Setup game dimension (screen width & height) before-hand and use the same settings while developing / testing
Programming the AI (so to speak) / NPCs is always more difficult than what you initially assume
Dropbox is awesome to host your blog content
Desolate Racers - WIP 03
I redesigned my POD, I was too bored to code the whole of last week x_x
I've added energy binders too.
My POD was kinda unstable at high speeds and flipped over when turning at high speeds.
I added Anti-roll code based on some unity tuts. It helped but didn't solve the problem... I've set this POD to max out at 450 kmph ( I know O_o ) and anything above 250 flips over ( I don't know how Veyron pulls it off x_x )
As of now, the workaround is cutting down POD speed when users turn at speeds above threshold.
Things remaining -
Few more particle systems
Movement of gliders
Modelling THE Circuit [bow]
UI Layer ( Yuk.. x_x )
I've added energy binders too.
My POD was kinda unstable at high speeds and flipped over when turning at high speeds.
I added Anti-roll code based on some unity tuts. It helped but didn't solve the problem... I've set this POD to max out at 450 kmph ( I know O_o ) and anything above 250 flips over ( I don't know how Veyron pulls it off x_x )
As of now, the workaround is cutting down POD speed when users turn at speeds above threshold.
Things remaining -
Few more particle systems
Movement of gliders
Modelling THE Circuit [bow]
UI Layer ( Yuk.. x_x )
Desolate Racers - WIP 02
Update on Desolate Racers ( ok the name sounds silly now x_x)
I changed my Spaceship to a POD, Skywalker's POD to be precise! Always wanted to drive one of those things...on Tatooine. I added 2 Suns to make myself feel at home ( When I add 3... it looks stupid o_O )
Here's a small-stinky-very-very-low quality video of it -
Things to be done:
Particle Systems
Energy Binders (looks stupid now doesn't it x_x)
Improving Game mechanics
Create the Legen.. wait for it.. dary Boonta Eve Circuit
Things I learnt:
You can't scale a Terrain in Unity3D. Only way I could think of is export heightmap in RAW format, scale it outside, import it back.. which sucks. So, lesson learnt.. get the scale right from the beginning. And no, you can't scale down everything else cos you got the terrain wrong. It hurts the physics bad.
I changed my Spaceship to a POD, Skywalker's POD to be precise! Always wanted to drive one of those things...on Tatooine. I added 2 Suns to make myself feel at home ( When I add 3... it looks stupid o_O )
Here's a small-stinky-very-very-low quality video of it -
Things to be done:
Particle Systems
Energy Binders (looks stupid now doesn't it x_x)
Improving Game mechanics
Create the Legen.. wait for it.. dary Boonta Eve Circuit
Things I learnt:
You can't scale a Terrain in Unity3D. Only way I could think of is export heightmap in RAW format, scale it outside, import it back.. which sucks. So, lesson learnt.. get the scale right from the beginning. And no, you can't scale down everything else cos you got the terrain wrong. It hurts the physics bad.
Desolate Racers - WIP 01
Trying out Terrain Sculpting in Unity.
Some WIP screen-shots -
Me calling it Desolate Racers - courtesy Wordweb ( You know desert... synonym... x_x )
Some WIP screen-shots -
Me calling it Desolate Racers - courtesy Wordweb ( You know desert... synonym... x_x )
My 1st Game - In Unity3D
What better way to learn Unity3D than porting my old XNA prototype?
I put this up in a week's time - 1 to 2 hrs per day after work.
Few In-Editor Shots:
I was too lazy to design a level for this (unlike my XNA attempt). All the blocks created at run-time.
This triggered a new concept I wanna try - POD RACER! (obviously on Tatooine)
NTFS: Prototyping "Skyroads" is a religious thing from now on.. Peace o_O \m/
I put this up in a week's time - 1 to 2 hrs per day after work.
Few In-Editor Shots:
I was too lazy to design a level for this (unlike my XNA attempt). All the blocks created at run-time.
This triggered a new concept I wanna try - POD RACER! (obviously on Tatooine)
NTFS: Prototyping "Skyroads" is a religious thing from now on.. Peace o_O \m/
Unity - Blue Blast Effect
I've been trying out Unity and I must say, IT'S FRIGGIN AWESOME \m/
I couldn't believe it's so light weight either!
I was trying out my hands at the in-built Particle System. After seeing some of the samples, the very first thing that came to my mind was the Blue-Blast effect in Transformer's Chopper scene.
Well, this is my first attempt.
Kinda looks alright in the beginning, but as the ripple spreads out, gaps appear. I'm thinking of other better-slicker-elegant ways to achieve this effect.
Actually, I'm so tempted to start creating a level editor for Away3D / XNA right now!I know I know... it's like adrenaline rush... and I'm lazy.
Why did I stop playing with Away3D?
1. There is no editor.. bummer.
2. Unity is planning a "publish to Flash Player 11" (Molehill as of now)
3. I'm lazy and I find good reasons to convince myself
I couldn't believe it's so light weight either!
I was trying out my hands at the in-built Particle System. After seeing some of the samples, the very first thing that came to my mind was the Blue-Blast effect in Transformer's Chopper scene.
Well, this is my first attempt.
Kinda looks alright in the beginning, but as the ripple spreads out, gaps appear. I'm thinking of other better-slicker-elegant ways to achieve this effect.
Actually, I'm so tempted to start creating a level editor for Away3D / XNA right now!I know I know... it's like adrenaline rush... and I'm lazy.
Plus, Unity is probably THE example for Component/Entity based design
NTFS: Why did I stop playing with Away3D?
1. There is no editor.. bummer.
2. Unity is planning a "publish to Flash Player 11" (Molehill as of now)
3. I'm lazy and I find good reasons to convince myself
Subscribe to:
Posts (Atom)




































