From 03482c8131b030b42fd22fba8d50dfec9c80a4e7 Mon Sep 17 00:00:00 2001 From: tyson-kubota Date: Sun, 24 Mar 2013 22:05:25 -0400 Subject: [PATCH] wormcrawl improvements; set pingpong vs loop as variables. collisions between iTween pathTo and a moving rigidbody are broken. --- FallingPlayer.js | 3 ++- WormCrawl.js | 4 +++- WormDeath.js | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 WormDeath.js diff --git a/FallingPlayer.js b/FallingPlayer.js index 5b6365b..9eaf5a8 100644 --- a/FallingPlayer.js +++ b/FallingPlayer.js @@ -167,7 +167,8 @@ function OnCollisionEnter (collision : Collision) { isPausable = false; lifeCountdown.LifeFlashTextureScript.FadeFlash (1, FadeDir.Out); UIscriptComponent.HideGUI(); - yield DeathRespawn (); + //Debug.Log("You died in a fatal collision with " + collision.gameObject); + yield DeathRespawn (); //isPausable = true; //UIscriptComponent.UnhideGUI(); } diff --git a/WormCrawl.js b/WormCrawl.js index ca4144f..ec09f6b 100644 --- a/WormCrawl.js +++ b/WormCrawl.js @@ -2,9 +2,11 @@ var pathName : String = "WormLoop"; var crawlTime : int = 15; +var Loop : boolean = false; function Start () { - iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath(pathName), "looptype", "pingPong", "orienttopath", true, "looktime", 1.0, "lookahead", 0.05, "time", crawlTime, "easetype", "linear")); +if (Loop == true) {iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath(pathName), "looptype", "loop", "orienttopath", true, "looktime", 1.0, "lookahead", 0.05, "time", crawlTime, "easetype", "linear"));} +else {iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath(pathName), "looptype", "pingPong", "orienttopath", true, "looktime", 1.0, "lookahead", 0.05, "time", crawlTime, "easetype", "linear"));} } function Update () { diff --git a/WormDeath.js b/WormDeath.js new file mode 100644 index 0000000..8803c28 --- /dev/null +++ b/WormDeath.js @@ -0,0 +1,17 @@ +#pragma strict + +function Start () { + +} + +function Update () { + var hit : RaycastHit; + if (Physics.Raycast (transform.position, Vector3.up, hit, 100)) { + //Debug.Log(hit.distance); + if (hit.rigidbody != null && lifeCountdown.isAlive == 1) { + Debug.Log(hit.distance); + lifeCountdown.isAlive = 0; + GetComponent(FallingPlayer).DeathRespawn (); + } + } +} \ No newline at end of file