Category Archives: Development

iTween

iTween must be one of the single most usefull scripts that are available. There is just one thing that makes working with it slightly obscure, because of the way extended options have to be added via the hash table by using the iTween.Hash() function. iTween.MoveTo(exhibitObject, iTween.Hash( “position”, presenterTransform.position, “time”, reloadDelay, “islocal”, false, “easetype”, iTween.EaseType.easeOutQuad ));

Realtime Cubemap for Reflections

A nice script for creating a real time cubemap from an object position for use with a reflection shader to create realtime reflections in Unity. Converted from the JavaScript example. Note: This script requires the Unity Pro license. using UnityEngine; using System.Collections; public class RealtimeCubemap : MonoBehaviour {     public int cubemapSize = 128;    [...]

String formatting

Something small but usefull is the String.Format function, with which you can format your numerical outputs: using System; using System.Collections; … // formatted float with three zero padded digits // in front of the “.” and three digits after it. debugText += String.Format(“H{0:000.000}\n”, heading); // formatted int with formats for positive;negative;zero values debugText += String.Format(“S{0:+000;-000; [...]

Calculate intersection between to lines

Here’s something that will calculate where two lines will intersect. If they don’t intersect then the two resulting vectors will mark the points where both lines are closest together. /* setup vectors */ Vector3 l1begin = playerCurrentPosition; Vector3 l1end = playerTargetPosition – l1begin; Vector3 l2begin = enemyCurrentPosition; Vector3 l2end = enemyTargetPosition – l2begin; /* calculate [...]

Calculate angle from current heading to target object

If you want to have an object turn automatically towards a target then you have to find out in which direction to turn. The usual angle function just returns the smallest angle between the current heading and the heading towards the target but not which way around. Vector3 lTarget = transform.InverseTransformPoint(target.position); targetDistance = lTarget.magnitude; targetAngle [...]

Get Vector3 from Quaternion / Rotate Vector3

To get the vector from a quaternion rotation you simply multiply the quaternion by the forward vector. Debug.DrawRay(transform.position, transform.rotation * Vector3.forward, Color.red); This also effectively rotates the forward-vector with the rotation of the transform, positioning it relative to the rotation of the actual object.

Unity Stunt Car Racer v03

Added a whole new track with better curves and everything. I tried to build the track from separate segments which I wanted to combine in Unity but it was quite tricky building all parts in Lightwave and then getting them to fit in Unity. Therefore I prebuilt the track and imported it as one model [...]

Unity Stunt Car Racer v02

Did a quick 3d off-road car in Lightwave for this project and integrated it into the scene. Also added a boost via the fire button (ctrl.) and a camera control script. It also should be much more difficult to tip the car over, but the car will not slide yet. SCR002

Unity Stunt Car Racer

Had a scan through another bunch of old Amiga games and stumbled across Geoff Crammonds excellent Stunt Car Racer. Knowing that Unity had some sort of vehicle physics (albeit not very good ones) I wanted to have a go at this myself. Here’s what I have come up until now. SCR v01

Unity Catapult v03

Added shields and the energy pads, that will power the shields. At the moment the shields just protect the catapult and will vanish when hit. In the next version the energy pads will replenish the shields as long as they are not blocked by the projectiles that are being dropped. http://game.lychesis.net/CP003.html