Firewall

Wednesday, April 14, 2010


Wow! Unity is just amazing. Sean McDonald modeled the sidewinder missile used in this game. Firewall was inspired by Unity's free Detonator Library. I got the metal texture for the blocks from desizntech.info. Which brings me to my next point, Unity makes mip and bump mapping a snap! Drag a texture onto a 3D asset, then click on the image in your library and click generate bump map...done! The UI even has a slider to control mip mapping and shininess of the bump mapping.

Firewall uses a lot of object oriented C# scripting for each gameObject. It's very easy to get things to work once you understand Vector3s and Quaternions. What's the hardest part? Any GUI or HUD work is really just a pain!

The levels in Firewall are XML driven, you can sneak a peak from my levels.xml document.
Each level is made up of a node, where each | represents the end of a line and each number is a stack of cubes.
...........|
...45554...|
...........|
...........|
...........|
...........|
...........|

Functionality:
Getting the missile to shoot at the mouse, but take on the cameras transform:

GameObject rocket = Instantiate(Resources.Load("Rocket")) as GameObject;
rocket.rigidbody.transform.position = camera.transform.position;
rocket.rigidbody.transform.rotation = Quaternion.LookRotation(Camera.main.ScreenPointToRay(Input.mousePosition).direction);
rocket.rigidbody.velocity = transform.TransformDirection(new Vector3(r.direction.x * 50, r.direction.y * 50, r.direction.z * 50));


Getting the 3D object that is under the mouse, to turn red. Also referencing variables in a dynamic prefab's class:

//raycast directly under the mouse for a distance of 100, return the first object that is hit.
Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

//if the ray hit an object, parse it as a Cube (Cube is the .cs class for the block prefab) and selected is a public bool.
if(Physics.Raycast(r, out hit, 100))
(hit.collider.gameObject.GetComponent("Cube") as Cube).selected = true;

//inside of Cube.cs on update we have the following:
rigidbody.renderer.material.color = selected ? Color.red : Color.white;

1 comments:

psxn122 said...

all 9s is a fun level...good finish

Post a Comment