Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 함수
- 다이어트
- 리눅스
- sqlite
- node.js
- mssql
- PyQt
- python
- PER
- Unity
- tensorflow
- GIT
- flutter
- Excel
- ubuntu
- MS-SQL
- 날짜
- Linux
- ASP
- 맛집
- IOS
- port
- pandas
- urllib
- MySQL
- PyQt5
- 유니티
- javascript
- 라즈베리파이
- swift
Archives
아미(아름다운미소)
유니티 이미지 플립 (오브젝트 이미지 뒤집기) 본문
유니티에서 이미지를 뒤집어야 할 경우가 종종 있는데요. 플레이어가 왼쪽에서 오른쪽으로 또는 오른쪽에서 왼쪽으로 이동시 이미지는 오른쪽이나 왼쪽 한장만 있을 시 오브젝트의 이미지를 플립 하시면 되는데요. 오브젝트의 이미지를 플립하는 두가지 방법 입니다.
1. 오브젝트의 스케일을 조정해서 뒤집는 방법
2. 오브젝트의 메트리얼의 타일링을 이용해서 뒤집는 방법
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 31 32 33 34 35 36 | using UnityEngine; using System.Collections; public class CsFly : MonoBehaviour { public int speed = 5; // Use this for initialization void Start () { } // Update is called once per frame void Update () { float key = Input.GetAxis( "Horizontal" ); float amtMove = speed * Time.smoothDeltaTime; if (key > 0) { //왼쪽 이동 Vector3 scale = transform.localScale; scale.x = -Mathf.Abs(scale.x); transform.localScale = scale; transform.Translate(Vector3.right * amtMove * key); } else if ( key < 0) { //오른쪽이동 Vector3 scale = transform.localScale; scale.x = Mathf.Abs(scale.x); transform.localScale = scale; transform.Translate(Vector3.right * amtMove * key); } } } |
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 31 32 33 34 35 | using UnityEngine; using System.Collections; public class CsFly : MonoBehaviour { public int speed = 5; // Use this for initialization void Start () { } // Update is called once per frame void Update () { float key = Input.GetAxis( "Horizontal" ); float amtMove = speed * Time.smoothDeltaTime; if (key > 0) { //왼쪽 이동 Vector2 tiling = transform.renderer.material.mainTextureScale; tiling.x = Mathf.Abs(tiling.x); transform.renderer.material.mainTextureScale = tiling; transform.Translate(Vector3.right * amtMove * key); } else if ( key < 0) { //왼쪽 이동 Vector2 tiling = transform.renderer.material.mainTextureScale; tiling.x = -Mathf.Abs(tiling.x); transform.renderer.material.mainTextureScale = tiling; transform.Translate(Vector3.right * amtMove * key); } } } |
'랭귀지 > Unity' 카테고리의 다른 글
유니티 게임정보저장/로딩 (PlayerPrefs : SetInt, GetInt) 기능 (0) | 2018.04.14 |
---|---|
[Unity] 유니티 네비게이션(추적기능 AI) NavMashAgent (0) | 2018.04.11 |
Unity GetButton, GetButtonDown, GetButtonUp 설명 및 사용법 (0) | 2018.04.06 |
[Unity] 2D 점프 (0) | 2018.04.05 |
유니티 점프시 카메라이동 (0) | 2018.04.02 |