일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 길건너 친구들
- 오큘러스
- 드래곤 플라이트 모작
- XR
- 앱 배포
- 포트폴리오
- 오브젝트 풀링
- 멀티플레이
- 모작
- 드래곤 플라이트
- 연습
- 유니티
- 유니티 Json 데이터 연동
- Photon Fusion
- OVR
- Oculus
- HAPTIC
- ChatGPT
- 유니티 GUI
- 팀프로젝트
- 가상현실
- meta xr
- VR
- 개발일지
- 개발
- meta
- CGV
- 유니티 UI
- 팀 프로젝트
- input system
Archives
- Today
- Total
EasyCastleUNITY
ref 키워드 and Vector3.SmoothDamp 본문
사용시 원본이 변함
https://learn.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/ref
ref 키워드 - C# 참조
ref(C# 참조) 아티클 07/14/2023 기여자 19명 피드백 이 문서의 내용 --> 다음 컨텍스트에서 ref 키워드(keyword) 사용합니다. 참조로 인수 전달 메서드의 매개 변수 목록에 사용되는 경우 ref 키워드는 인
learn.microsoft.com
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RefMain : MonoBehaviour
{
void Start()
{
int age = 10;
this.SayHello(ref age);
Debug.Log(age);
}
void SayHello(ref int num)
{
num = num + 40;
}
}

무조건 적으로 변수 선언이 필요하다.
SmoothDamp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RefMain : MonoBehaviour
{
[SerializeField]
private Transform startTrans;
[SerializeField]
private Transform endTrans;
[SerializeField]
private Transform playerTrans;
private Vector3 velocity = Vector3.zero;
[SerializeField]
private float smoothTime = 1f;
private void Update()
{
//반환값 : 보간된 위치
this.playerTrans.position= Vector3.SmoothDamp(playerTrans.position, endTrans.position, ref velocity,this.smoothTime);
Debug.LogFormat("<color=lime>velocity:{0}</color>", this.velocity); //증가하다가 도착할 때즘 되면 다시 감소해서 0으로
}
}

'개인 필기' 카테고리의 다른 글
2023/08/22 필기 (0) | 2023.08.22 |
---|---|
2023/08/21 필기 (0) | 2023.08.21 |
Lerp and Slerp (0) | 2023.08.18 |
정규화 벡터 (0) | 2023.08.18 |
유니티 라이프 사이클 (0) | 2023.08.16 |