반응형
환경 설정
1. unity hub 다운로드
창의적인 프로젝트 시작 및 Unity Hub 다운로드 | Unity
간단한 3단계로 Unity를 다운로드하고 전 세계적으로 가장 큰 인기를 누리는 2D/3D 멀티플랫폼 경험 및 게임 제작용 개발 플랫폼을 사용하세요.
unity.com
2. unity hub 실행 후 계정 생성

3. unity hub 계정으로 로그인 후 unity engine 설치
- install editor 클릭

- official release > LTS(Long-Term Support) 붙은 버전 다운로드

- WebGLBuild Support 선택 (설치 후에도 변경 가능)

4. 설치 완료

프로젝트 설정
1. new project > universal 2D
- new project 클릭

- universal 2D 템플릿 선택 후 project name, location 지정 후 create project

2. 설치 완료

3. assets 다운로드
- 아래 사이트에서 assets 다운로드
- Filter Mode = Point (no filter), Compression = None 으로 설정 후 apply

BackGrounds
1. 3D Object > Quad 생성

2. Quad에 구름 이미지 넣고 Wrap mode = repeat으로 선택


3. Repeat으로 설정 시 Materials 폴더 하위에 이미지 생성됨. 이때 이 이미지의 Tilling의 x축을 2개, y축을 1개로 해서 설정

4. Building의 Surface Type = Transparent, Tilling의 x축 2개, y축 1개로 설정

Scrolling Scripts

using UnityEngine;
public class BackgroundScroll : MonoBehaviour
{
[Header("Settings")]
[Tooltip("How fast the texture scroll speed?")]
public float scrollSpeed;
[Header("References")]
public MeshRenderer meshRenderer;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
meshRenderer.material.mainTextureOffset += new Vector2(scrollSpeed * Time.deltaTime, 0);
}
}
Player Jump
1. player에 Rigidbody 2D, Box Colider 2D추가


2. platform에Box Colider 추가

3. Player Script
using UnityEngine;
public class Player : MonoBehaviour
{
[Header("Settings")]
public float jumpForce;
[Header("References")]
public Rigidbody2D playerRigidBody;
private bool isGrounded = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
//playerRigidBody.linearVelocityX = 10;
//playerRigidBody.linearVelocityY = 20;
playerRigidBody.AddForceY(jumpForce, ForceMode2D.Impulse);
isGrounded = false;
}
}
// collision happened
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.name == "Platform")
{
isGrounded = true;
}
}
}
참고 >>
https://www.youtube.com/watch?v=A58_FWqiekI
반응형
'개발' 카테고리의 다른 글
| [netlify] Cafe24에서 구입한 도메인을 Netlify에 연결하는 가이드 (0) | 2025.08.26 |
|---|---|
| [netlify] GitHub 프로젝트를 Netlify에 배포하는 방법 (0) | 2025.08.25 |
| [swagger] string format(date, date-time, password, byte, binary) 스웨거 (0) | 2024.09.27 |
| kubernetes. failed to create deployment.app already exists (5) | 2024.09.01 |
| docker. docker push 시 denied: requested access to the resource is denied, github (0) | 2024.08.23 |