Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Feliponcio : MonoBehaviour {
  6.  
  7.    
  8.     public Vector2 [] Movimientos;
  9.     public float _velocity;
  10.     public Vector2 PosInicial;
  11.     public float _magnitud;
  12.     public Vector2 _resultante;
  13.     // Use this for initialization
  14.     void Start()
  15.     {
  16.        PosInicial = transform.position;
  17.         for (int i = 0; i < Movimientos.Length; i++)
  18.         {
  19.             _resultante += Movimientos[i];
  20.         }
  21.         _magnitud = Mathf.Sqrt(Mathf.Pow(_resultante.x, 2)+ Mathf.Pow(_resultante.y, 2));
  22.     }
  23.            
  24.     // Update is called once per frame
  25.     void Update()
  26.     {
  27.         transform.position = Vector3.MoveTowards(transform.position, PosInicial + _resultante, _velocity * Time.deltaTime);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement