Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created February 28, 2015 13:41
Show Gist options
  • Select an option

  • Save baba-s/6088b77a225cc8a6da4b to your computer and use it in GitHub Desktop.

Select an option

Save baba-s/6088b77a225cc8a6da4b to your computer and use it in GitHub Desktop.
UnityEngine = luanet.UnityEngine
System = luanet.System
gameObject = UnityEngine.GameObject
vector3 = UnityEngine.Vector3
quaternion = UnityEngine.Quaternion
color = UnityEngine.Color
time = UnityEngine.Time
primitiveType = UnityEngine.PrimitiveType;
abs = System.Math.Abs
sin = System.Math.Sin
sqrt = System.Math.Sqrt
if cube == nil then
cube = gameObject.CreatePrimitive( primitiveType.Cube )
end
function update( dt )
t = time.realtimeSinceStartup
y = sin( t )
a = sin( 1 + 3 * t )
r = abs( sin( 2 + 1.5 * t ) )
g = abs( sin( 3 + 1.6 * t ) )
b = sqrt( 1 - r * r - g * g )
cube.transform.position = vector3( 0, y, -5 )
cube.transform.rotation = quaternion.AngleAxis( 60 * t, vector3( a, 1, 0 ) )
cube.renderer.material.color = color( r, g, b )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment