Advertisement
Guest User

eewuiwweerw

a guest
Jul 30th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Movimento2 : MonoBehaviour {
  5.    
  6.     public Vector2 target1 = new Vector2 (-11,4);
  7.     public Vector2 target2 = new Vector2 (0,0);
  8.     public float speed=1;
  9.     public float i=0;
  10.     private static Vector3 puntoA ;
  11.     private static Vector3 puntoB ;
  12.     // Use this for initialization
  13.     void Start () {
  14.         puntoA = new Vector3(target1.x, target1.y,0) - transform.position ;
  15.         puntoB = new Vector3(target2.x, target2.y,0) - transform.position ;
  16.         }// end void start
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.         Debug.Log("i: " +i);
  21.         Debug.Log("transform.position.x: " + transform.position.x + " puntoA.x: " + puntoA.x);
  22.         Debug.Log("transform.position.y: " + transform.position.y + " puntoA.y: " + puntoA.y);
  23.         Debug.Log("transform.position.x: " + transform.position.x + " puntoB.x: " + puntoB.x);
  24.         Debug.Log("transform.position.y: " + transform.position.y + " puntoB.y: " + puntoB.y);
  25.  
  26.         if (i==0)
  27.         {
  28.            
  29.             if ( (transform.position.x >= puntoA.x) && (transform.position.y <= puntoA.y) ) //x della Meella maggiore a -11 e y inferiore a 4
  30.             {
  31.                 transform.Translate (puntoA.normalized* speed* Time.deltaTime) ;
  32.             } //end insideIf
  33.             else
  34.             {
  35.                 ++i;
  36.             } //end insideElse
  37.         } //end If
  38.        
  39.         if (i==1)
  40.         {
  41.            
  42.  
  43.             if ( (transform.position.x <= puntoB.x) && (transform.position.y >= puntoB.y) ) //x della Mella inferiore a 0 e y maggiore a -1
  44.             {
  45.                 transform.Translate (puntoB.normalized* speed* Time.deltaTime) ;
  46.             }//end insideIf
  47.             else
  48.             {
  49.                 ++i;
  50.             }//end insideElse
  51.            
  52.         }//end If
  53.     }//end voidUpdate
  54. } //end Movimento2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement