코드 흐름은 선언 -> 초기화 -> 호출
RigidBody 관련 코드는 FixedUpdate에 작성해야 한다. (권장)
ForceMode : 힘을 주는 방식(가속, 무게 반영)
스페이스바 누르면 점프하기
Rigidbody rigid; //선언
// Start is called before the first frame update
void Start()
{
//초기화
rigid = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
// rigid.velocity = new Vector3(2, 4, -1);
if(Input.GetButtonDown("Jump"))
{
rigid.AddForce(Vector3.up * 5, ForceMode.Impulse); //힘으로 밀기
}
}
회전력
AddTorque(Vec): Vec 방향을 축으로 회전력이 생김.
rigid.AddTorque(Vector3.up);