반응형 앱 만들기/유니티2D 게임 만드는 방법55 유니티 키 입력하기 1. 키보드 입력하기 void Update() { if(Input.GetKeyDown(KeyCode.Space) && transform.position.y = 0.0f); } 2. buttonName 입력하기 void Update() { if(Input.GetButtonDown("Fire1") && transform.position.y = 0.0f); } buttonName은 하기메뉴에서 키보드와 매핑되어있음. 예) "Fire1 = left Crtl" E.. 2019. 2. 13. 유니티 오브젝트 스크롤 시키기. 유니티 오브젝트 스크롤 시키기. public class ScrollObject : MonoBehaviour{ public float speed = 1.0f; public float startPosition; public float endPostion; // Update is called once per frame void Update() { // 매 프레임마다 X포지션으르 조금씩 이동시킨다. transform.Translate(-1 * speed * Time.deltaTime, 0, 0); if (transform.position.x 2019. 2. 12. 유니티 - 스와이프 길이 구하기 유니티 - 스와이프 길이 구하기 using System.Collections;using System.Collections.Generic;using UnityEngine; public class Car : MonoBehaviour{ Vector2 startPos; Vector2 endPos; float swipeLength; float speed; // Update is called once per frame void Update() { // 스와이프 길이를 구한다. // 마우스를 클릭했을때 혹은 폰 화면을 터치하면. if (Input.GetMouseButtonDown(0)) { this.startPos = Input.mousePosition; }else if (Input.GetMouseButtonUp(0.. 2019. 2. 7. 유니티 - animation event has no function name specified 이벤트 오류시 하기이미지 애니메이션 타임라인의 마커(Animation Event)를 삭제한다. * 즉, 등록된 이벤트에 연결된 함수가 없기에 발생하는 문제임. 2019. 2. 4. 플레이어가 화면(Y축) 밖으로 나갔는지 확인하기 플레이어가 화면(Y축) 밖으로 나갔는지 확인하기 //플레이어가 화면밖으로 나갔는지 체크하기. if(transform.position.y < -10) { //플레이어가 화면밖으로 나가면 특정씬으로 이동하도록. SceneManager.LoadScene("GameScene"); } 2019. 2. 2. 유니티 - 플레이어에게 힘을 주기 유니티 - 플레이어에게 힘을 주기Rigidbody2D 컴포넌트의 Addforce 메서드를 사용하면 된다.using System.Collections;using System.Collections.Generic;using UnityEngine;public class PlayerController : MonoBehaviour{ Rigidbody2D rigid2D; float jumpforce = 300.0f; // Start is called before the first frame update void Start() { this.rigid2D = GetComponent(); } // Update is called once per frame void Up.. 2019. 1. 30. 유니티에서 안드로이드 진동시키기. 해당 함수를 호출하면 안드로이드에서 진동이 발생함. Handheld.Vibrate(); 2019. 1. 19. 유니티 일정시간후 함수호출 유니티 일정시간 후 함수호출 Invoke("FunctionName", 1.0f); // 1초후에 " " 에 기재한 함수를 실행하라. 1초후 FunctionName() 호출됨. (여러 용도로 사용이 용이함) 2019. 1. 19. 유니티 - 보상광고 달기 유니티 - 보상광고 달기 using UnityEngine;using UnityEngine.UI;using UnityEngine.Advertisements; public class UnityAdsManager_Rewarded : MonoBehaviour{public void ShowRewardedAd(){if (Advertisement.IsReady("rewardedVideo")){ // 광고가 끝난 뒤 콜백함수 "HandleShowResult" 호출 var options = new ShowOptions { resultCallback = HandleShowResult };Advertisement.Show("rewardedVideo", options);}} // 광고가 종료된 후 자동으로 호출되는 콜백 함수.. 2017. 7. 31. 이전 1 ··· 3 4 5 6 7 다음 반응형