Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BlueCube : MonoBehaviour {
- public float speed, distance;
- Vector3 position, direction, direction2;
- // Use this for initialization
- void Start() {
- direction = new Vector3(1, 0, 0);
- direction2 = new Vector3(0, 1, 0);
- position = transform.position;
- }
- // Update is called once per frame
- void Update() {
- position += direction * Mathf.Cos(Time.time * speed) * distance * Time.deltaTime;
- position += direction2 * Mathf.Sin(Time.time * speed) * distance * Time.deltaTime;
- transform.position = position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement