반응형
- 공전
public class MoonRevolution : MonoBehaviour
{
public Transform target;
[Range(0, 100)]
public float rotateSpeed = 10f;
private void Update()
{
transform.RotateAround(target.transform.position, new Vector3(0, 1, 0), rotateSpeed * Time.deltaTime);
}
}
- 자전
public class EarthRotation : MonoBehaviour
{
[Range(0, 100)]
public float speed = 25f;
private void Update()
{
transform.Rotate(new Vector3(0, 1, 0) * speed * Time.deltaTime);
}
}
참고할만한 글
유니티 C# 오브젝트 목표 지점까지 이동시키기 간단 구현
코드 작성 using UnityEngine; public class ObjectMovement : MonoBehaviour { // 목표 지점을 설정합니다. public Transform targetPoint; // 이동 속도를 조절할 변수를 설정합니다. public float moveSpeed = 5f; void Update() { // 목
parksh3641.tistory.com
유니티 C# 캐릭터 주변 원 운동 오브젝트 간단 구현 및 데미지 주기
코드 작성 using UnityEngine; public class RotatingDamageObject : MonoBehaviour { public float rotationSpeed = 10f; public float damageAmount = 10f; public float detectionRadius = 2f; private void Update() { transform.RotateAround(Vector3.zero, Vector3.
parksh3641.tistory.com
반응형