topical media & game development

talk show tell print

lib-unity-tutorial-gameplay-Assets-Scripts-2D-Moving-Platform-PlatformMover.js / js



  var targetA : GameObject;
  var targetB : GameObject;
  
  var speed : float = 0.1;
  
  function FixedUpdate () {
          var weight = Mathf.Cos(Time.time * speed * 2 * Mathf.PI) * 0.5 + 0.5;
          transform.position = targetA.transform.position * weight
                                                  + targetB.transform.position * (1-weight);
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.