유니티(unity)

[1분 해결] 유니티(unity) - 객체(object) 움직이기 with 가속도

개발자 고포고 2021. 10. 27. 16:00
반응형

기본적으로 유니티에서 객체를 움직이는 방법은 다양하지만 일반적으로 2가지를 사용한다.

 

 

1.transform position 이용

-객체의 포지션 값을 조정하여 이동한다.

gameobject.transform.position = Vector3.MoveTowards(gameobject.transform.position, target.transform.position, speed * Time.deltaTime);

 

2.rigidbody addforce 이용

-객체의 포지션 값을 조정하여 이동한다.

 gameobject.GetComponent<Rigidbody>().AddForce(new Vector3(0,0, moveSpeed));

 

 

[tag]

#AddForce #gameobject #movespeed #position #rigidbody #transform #unity #객체이동 #움직이기 #유니티

반응형