Wednesday, 9 October 2013

Steampunk Scripting

Here I was looking for some simple code to run animations on mouse down I found it in the book that I had brught myself below.



















But also i looked at the code from a guy called Edithson Abelard who dose tutorals for maya into unity. there is a link and video below.

http://www.youtube.com/watch?v=PvmMyMklwyo


Using this simple code as shown blow I will be able to run animations in unity from a click of a buttom.

#pragma strict
var doorObj:GameObject;
var isOpen = false;

var timeBeforeNextAnimation :float = 0;

function OnMouseDown(){
 Debug.Log("mouse is down");

 if( timeBeforeNextAnimation < Time.time )
 {
  if(!this.isOpen){
   doorObj.animation.Play("open");
   this.isOpen = true;
  }else{
   doorObj.animation.Play("close");
   this.isOpen = false;
  }

  timeBeforeNextAnimation = Time.time + 3;

 }
}

function Start () {
}
function Update () {
}

No comments:

Post a Comment