Day 14 ~ Day 17 - pathway - Unity Essentials - Programming Essentials
Unity Essentials - Editor Essentials 읽어보면서 정리한 거
https://learn.unity.com/pathway/unity-essentials?version=6
Unity Essentials 의 네 번째 과정: Programming Essentials
4_LivingRoom_Programming_Scene 에서
❗처음에 만든 Script file 명을 나중에 바꾸지 마라. 나중에 문제 일으킬 수 있다.
이름을 바꾸고 싶으면, 삭제 후 새로 만들어라가 가이드
MainCamera 를 Player GameObject 의 child 로 넣고 아래와 같이 해두면
진행 방향 뒤에서 보는 식으로 되네.. 신기..
... position the camera to follow the player in a third-person view, which will be more immersive and intuitive.
❗연결된 스크립트의 Public 속성값을 Play 모드에서도 변경하는 경우에 바로 바로 적용이 되어서 적절한 값을 찾는데 도움이 되지만, Play 모드가 종료되면 값이 사라진다. 기억해 두어야 할 속성값이 많으면 Play 모드에서 Copy Component 해두고, 종료 후에 Paste Component 해두면 값이 그대로 적용 된다
PlayerController.cs
A Rigidbody provides a physics-based way to control the movement and position of a GameObject.
https://docs.unity3d.com/Manual/class-Rigidbody.html
4. Review the structure of the default script 에서 기본 코드 설명
GameObject 를 선택하고,
Global 에서 Local 로 바꾸면
Transform 에서 Rotation 의 Y 값을 바꾸면 그에 대한 변화가 바로 Scene 에서 보임
Global 로 되어 있으면 바꿔도 Scene 에서 업데이트 안됨
✅ Shift 를 누른 상태에서 Y 값을 드래그 (drag) 하게 되면 값이 더 크게 변경
=> Unity runs this function once per frame
Games typically run at 30-60 frames per second
Rotate the collectible object 1 degree around the Y-axis in each frame,
✅ Play mode 에서도 Scene 로 전환해서 동작하는 모습을 볼 수 있다
public member variable 을 통해서 inspector window 에서 값을 지정할 수 있다
2. Allow the player to go through the collectible 에서
Collider component 의 IsTrigger 속성
Collider 컴포넌트가 물리적인 충돌 대신에 trigger 처럼 행동하도록 설정하는 것
When you tell a collider component to act as a trigger instead of a physical collider, it will no longer have a sold barrier, but it can still detect entry by the player or other GameObjects.
3. Add the OnTriggerEnter function 에서
❗OnTriggerEnter is only called if at least one of the objects involved has a Rigidbody component attached to it.
5. Destroy the collectible 에서
여기서 GameObject 는 script 가 attach 된 그 GameObject 를 말한다..
6. Explorer particle effect options 에서
Visual Effects (VFX) - like puffs of smoke or mini explosions
유니티에서는 불, 연기, a burst of sparks 와 같은 복잡한 visual 효과를 시뮬레이션하기 위해서 particle systems 를 이용한다
Particles panel
7. Create and assign a new variable for the particle 에서
Hold the reference to your particle effect prefab
스크립트에서 GameObject type 의 변수를 추가하고, prefab 에서 드래그 & 드랍으로 지정해준다
8. Instantiate the partcle 에서
❗ Instantiating an object in Unity means creating a copy of it during runtime (while the application is running); your're making a new instance of that prefab in your scene.
한글로 쓰기 힘들어...😂
Instantiate 메소드는 아래 정보를 필요
- Which object to instantiate
- The position of the instantiated object
- The rotation of the instantiated object
collectible GameObject 의 transform (position, scale, rotation) 을 참조하면 된다....
10. Restrict collisions to the player only 에서
유니티에서는 tags 라고 불리는 피쳐(feature) 를 사용해서 플레이어 GameObject 를 구별할 수가 있다...
댓글
댓글 쓰기