Ln Go

Orbit 본문

Unity/Quad Action

Orbit

Ln Ro 2021. 6. 4. 02:23
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Orbit : MonoBehaviour
{
    public Transform target;
    public float orbitSpeed;
    Vector3 offset;

    void Start()
    {
        offset = transform.position - target.position;
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = target.position + offset;
        transform.RotateAround(target.position, Vector3.up, orbitSpeed * Time.deltaTime);
        offset = transform.position - target.position;
    }
}

'Unity > Quad Action' 카테고리의 다른 글

Item  (0) 2021.06.04
StartZone  (0) 2021.06.04
Missile  (0) 2021.06.04
Bullet  (0) 2021.06.04
Grenade  (0) 2021.06.04
Comments