아카이브
포탈 텔레포트 본문
플레이어가 포탈에 충돌할 경우 생성될 위치를 지정한다
Player에 PortalManager 스크립트 추가
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class portalManager : MonoBehaviour
{
public Transform APos;
public Transform BPos;
private void OnTriggerEnter(Collider col)
{
if (col.CompareTag("Portal A"))
{
CharacterController cc = GetComponent<CharacterController>();
cc.enabled = false;
transform.position = BPos.transform.position;
transform.rotation = new Quaternion(transform.rotation.x, BPos.rotation.y, transform.rotation.z, transform.rotation.w);
cc.enabled = true;
}
if (col.CompareTag("Portal B"))
{
CharacterController cc = GetComponent<CharacterController>();
cc.enabled = false;
transform.position = APos.transform.position;
transform.rotation = new Quaternion(transform.rotation.x, APos.rotation.y, transform.rotation.z, transform.rotation.w);
cc.enabled = true;
}
}
}
'3D 콘텐츠 제작' 카테고리의 다른 글
3D 프로젝트 발표 (0) | 2023.10.12 |
---|---|
플레이어 이동 (0) | 2023.09.25 |
포탈 만들기 (0) | 2023.09.25 |
3D 프로젝트로 제작할 게임 (0) | 2023.09.22 |