using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
this.rb.MovePosition(rb.position + this.transform.forward * Time.deltaTime);
}
private void OnCollisionEnter(Collision collision)
{
ContactPoint cp = collision.GetContact(0);
Quaternion rot = Quaternion.LookRotation(cp.normal);
this.transform.rotation = rot;
}
}
'유니티 심화' 카테고리의 다른 글
유니티 new Input System으로 조이스틱 사용하기 (0) | 2023.08.31 |
---|---|
가장 가까운 무기 장비하기 + 배럴 공격하기 (0) | 2023.08.21 |
궁수의 전설 (0) | 2023.08.20 |
유니티 카메라 줌인 + 회전 따라가기 (0) | 2023.08.17 |
유니티 슈팅게임 (0) | 2023.08.16 |