Tuesday, November 24, 2009

Scripting Progress

I'm new at scripting, and I'm under the impression that Unity has particularly accessible scripting for a game engine, only because I've been able to accomplish more than I expected to. I thought I'd rattle off some simple victories to give you an idea...

Learning via tutorials:
  • Setup a simple game environment with ground, light, and camera controllable on x/z plane.
  • Added ability to spawn instantiated objects with the press of a button.
  • Added a cube avatar to travel along with my camera.
  • Added script to immediately spawn a working rigidbody brick wall (5x5) also made of instantiated cubes.
  • Added rockets (cylinders) that shoot out as rigidbodies on button press.
Learning via API and hard knocks:
  • Added a spotlight to the camera.
  • Gave spotlight self-made light cookie to make it look like a proper flashlight
  • Added button to turn flashlight on/off, with sounds (click/cluck)
  • Added ability to spawn brick walls on button press at location and rotation in reference to camera.
  • Added a cylinder "avatar" with a sphere head and gave it a proper character controller (for proper movement with collision detection).
  • Rigged avatar to move like a Gears of War character (move character with left thumbstick, turn (l/r) character with right thumbstick)
  • Attached camera on offset to avatar so it moves like a Gears of War camera; added (u/d) rotation controlled with right thumbstick)
  • Gave avatar moving with proper character controller so collision works correctly; avatar can bump into brick walls, is affected by gravity and move around blocks
  • Adjusted rockets (cylinders) so they have rocket sounds attached, point light attached, sound attached, added script that destroys them on impact with instantiated explosion particle (fiery) when they smash into something so they are good at knocking around bricks dramatically.
  • Create sphere primitive, shoot ray from camera; on collision detection places sphere at collision place, and shoot rockets and flashlight at same said point (sphere is an ad hoc but extremely accurate reticle)
  • Added cube around level that detects when an object leaves it (think death plane) and destroys the object; also detects when avatar leaves and "respawns" him at origin of level.
  • Added background music.
  • Avatar with camera rotation rig similar to above
  • Added vertical extents to up/down looking
  • Added blocks and faux human characters for scene reference.
  • Added skybox.
  • Added nice-looking avatar model via Blender (stiff)
  • Added environment sounds and ability to make character noises with button presses
  • Added various states of travel, switchable by button with different speeds and adjustable camera settings
    • One locks avatar feet to ground with closer camera, and adds gravity
    • One lets you move through air freely a bit like an FPS (f/b/l/r on plane), but plane rotates according to camera view, letting you move anywhere in quickly
    • One is a distant camera that locks air movement to a plane
    • Camera views from one state to the next are the same, only distance changes
    • Avatar movement separate from camera so avatar can rotate and behave independent of camera focus
    • Camera offsets and speeds are completely tunable in game, on the fly
My PS3 Sixaxis is being used on the PC, so I can basically test any character control setup with button presses and roughed in effects by myself, tuning things until I like how the core abilities of a game feels. To have this power feels awesome. I bump into problems that can take tons of time to conquer, but I learn so much from slogging through them. AND, others have offered to help when said problems arise, for which I feel incredibly fortunate and grateful. Thank you!


  1. Good stuff man! Have any books or tutorials you recommend for scripting newbies?

  2. I'm afraid I don't know of any books. I found some of the info at http://www.w3schools.com/js/default.asp useful but it's web oriented. It was just the first place I looked for basics. I know the Unify community also has some tutorials but I haven't gone through much of it. http://www.unifycommunity.com/wiki/index.php?title=Tutorials

    I mostly slogged through things the hard way after going through the few tutorials Unity has on their site.