반응형
using System.Collections.Generic;
using UnityEngine;
public class Turn : MonoBehaviour {
RaycastHit Hit;
float TurnSpeed;
Quaternion dr;
Vector3 Click;
void Start () {
TurnSpeed = 10f;
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0)) {
Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out Hit);
Click = Hit.point;
dr = Quaternion.LookRotation ((Click - transform.position).normalized );
dr.x = 0;
dr.z = 0;
// 캐릭터 기울기 방지
transform.rotation = Quaternion.Slerp (transform.rotation, dr, TurnSpeed *Time.deltaTime);
}
}
}
반응형
'Programing > unity' 카테고리의 다른 글
유니티,unity, CharacterController 를 이용한 캐릭터이동 (0) | 2017.02.25 |
---|---|
유니티 ,unity.캐릭터 따라다니는 카메라 (0) | 2017.02.25 |
unity,유니티,3d 클릭시 이동,RaycastHit ,Raycast ,ScreenPointToRay (0) | 2017.02.25 |
유니티,unity, text 추가,텍스트 추가 (0) | 2017.02.24 |
unity,유니티,배경무한반복 (0) | 2017.02.24 |