Example #1
0
 public void moveTo(Vector2JSON[] route, Vector2JSON from)
 {
     playerObj.transform.position = new Vector3(from.x, 0, from.y);
     this.route = new Queue<Vector2JSON>();
     foreach (var sinep in route)
     {
         this.route.Enqueue(sinep);
     }
 }
Example #2
0
 void move(Vector2JSON nexttarget)
 {
     targetPosition = new Vector2(nexttarget.x, nexttarget.y);
     Vector2 pos = new Vector2(playerObj.transform.position.x, playerObj.transform.position.z);
     if (!V2Equal(targetPosition, pos))
     {
         Vector3 direction = new Vector3(targetPosition.x, 0, targetPosition.y) - new Vector3(pos.x, 0, pos.y);
         direction = new Vector3(direction.normalized.x, 0, direction.normalized.z);
         playerObj.transform.rigidbody.velocity = direction * 3;
     }
 }