기능 : PC AIM [에임기능]
에임기능 :
1. 스크린 가운데 에임이 줄타기 기능을 사용할 수 있을 때
에임이 검은색으로 바뀌고 줄타기 기능을 사욯알 수 없을 때 살짝 불투명하게 바뀐다.
2 .아이템이 있을 경우 마우스 왼쪽 버튼을 누르고 있으면 조준 에임으로 바뀐다.
줄타기 기능 : 어떤 물체를 Player가 바라볼 때 마우스 우클릭으로 그 물체에 공중에서 이동하는 기능
1. 에임이 검은색으로 바뀌고 , 회색, 불투명하게 바뀌는 기능
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TestCrossHair : MonoBehaviour
{
[SerializeField] private float distance = 10f;
[SerializeField] private Image circleImg;
private Color color;
private void Start()
{
this.color = this.circleImg.color;
}
void Update()
{
Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
DrawArrow.ForDebug(Camera.main.transform.position, Camera.main.transform.forward * this.distance, 0f, Color.green, ArrowType.Solid);
RaycastHit hit;
if (Physics.Raycast(ray.origin, ray.direction, out hit, this.distance))
{
//hit 된게 있다면
this.color.a = 1.0f;
this.circleImg.color = this.color;
}
else
{
//hit 된게 없다면
this.color.a = 0.5f;
this.circleImg.color = this.color;
}
}
}
Ray를 이용해 물체에 닿으면 color.a 값을 변경시켜주었다.
2. 아이템이 있을 경우 마우스 왼쪽 버튼을 누르고있으면 조준에임으로 바뀜
crossHair 그림을 구해서 SetActive를 False와 True 상태로 만들어주었다.
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[Giant vs Human 팀프로젝트/Unity] 줄타기 수정 (0) | 2023.12.18 |
---|---|
[Giant vs Human 팀프로젝트/Unity] 로켓발사위치 수정 (0) | 2023.12.18 |
[Giant vs Human/Unity] 개발일지 - [PC기능] (0) | 2023.12.14 |
[Giant vs Human/Unity] 개발일지 - 망치휘두르기 [PC기능] (0) | 2023.12.14 |
[Giant vs Human 팀프로젝트] 해머구현 (1) | 2023.12.07 |