[Unity] 특정 Game Object 주위를 회전시키게 하기

SYiee·2022년 11월 16일
0

Unity

목록 보기
1/13
post-thumbnail

공전

특정 오브젝트 주위를 회전 시키기

Transform.RotateAround(Vector3 point, Vector3 axis, float angle)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateCloud : MonoBehaviour
{
    public GameObject Planet;
    public float speed = 5.0f;

    void Update()
    {
        orbitAround();
    }

    void orbitAround()
    {
        transform.RotateAround(Planet.transform.position, Vector3.down, speed * Time.deltaTime);
    }
}

자전

스스로 빙글~빙글~ 돌기

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotatingSelf : MonoBehaviour
{
    private float speed = 10f;
    void Update()
    {
        Rotating();
    }
    void Rotating()
    {
        transform.Rotate(new Vector3(0,  0, speed * Time.deltaTime));
    }
}
profile
게임 개발자

0개의 댓글