예제 #1
0
 /**
  * Initialize components
  */
 void Start()
 {
     obj   = this.gameObject;
     spr   = this.gameObject.GetComponent <SpriteRenderer>();
     insul = this.gameObject.GetComponent <Field_Insulator> ();
     door  = this.gameObject.GetComponent <Field_Door> ();
     haz   = this.gameObject.GetComponent <Field_Hazard> ();
     move  = this.gameObject.GetComponent <Moving_Platform> ();
 }
예제 #2
0
    void Movement()
    {
        // Left to Right movement
        moveDirection.x = Input.GetAxis("Horizontal") * speed;

        // Sticking to platforms
        if (platform != null)
        {
            mPlatform = platform.GetComponent("Moving_Platform") as Moving_Platform;
            if (mPlatform.isMovingLeft())
                moveDirection.x -= mPlatform.speed;
            else
                moveDirection.x += mPlatform.speed;
        }
        platform = null;

        // Apply the transform
        moveDirection = transform.TransformDirection(moveDirection);
    }