Advertisement
BaneOfSmite

BlueieBoxie

Oct 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BlueCube : MonoBehaviour {
  6. public float speed, distance;
  7. Vector3 position, direction, direction2;
  8.  
  9. // Use this for initialization
  10. void Start() {
  11. direction = new Vector3(1, 0, 0);
  12. direction2 = new Vector3(0, 1, 0);
  13. position = transform.position;
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update() {
  18. position += direction * Mathf.Cos(Time.time * speed) * distance * Time.deltaTime;
  19. position += direction2 * Mathf.Sin(Time.time * speed) * distance * Time.deltaTime;
  20. transform.position = position;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement