본문 바로가기

KDT/유니티 기초22

23/08/07 AppleCatch ray를 찍은 위치로 바구니 위치 변경(칸에 맞춰서 이동 x) using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; public class BasketController : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //마우스 왼쪽 클릭하면(화면 터치) Ray를 만들자 if (Input.GetMouseButtonDown(0)) { //화면상의 좌표 -> Ra.. 2023. 8. 7.
23/08/06 [주말과제] 캐릭터 위치 이동 및 몬스터 공격(수정) 스크립트 예상해보기 1. 클릭한 곳을 월드좌표상 Ray객체로 생성 2. 클릭한 곳을 타겟으로 하여 캐릭터 이동시키고 멈추기 3. 몬스터가 타겟이 되면 공격 애니메이션 재생 4. 공격 중에 다른 곳을 클릭하면 클릭한 곳으로 다시 이동후 멈추기 1,2) 클릭한 곳까지 캐릭터 이동시키고 도착하면 멈추기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class DogController : MonoBehaviour { public Transform target; private Animator anim; private bool isMoveStart = false; private Vector3 targetPos.. 2023. 8. 6.
23/08/06 유니티 기초 복습(CatEscape, Bamsongi) 2. Bamsongi 1) 밤송이 던져서 과녁(타겟)에 맞춰서 붙게하기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class BamsongiController : MonoBehaviour { public Rigidbody rBody; [SerializeField] private float forwardForce = 2000; private void Awake() { this.rBody = this.GetComponent(); } // Start is called before the first frame update void Start() { Debug.Log("Start"); this.Shoot.. 2023. 8. 6.
23/08/05 유니티 기초 복습(Roulette, CarSwipe) 1. Roulette 마우스 클릭 (왼쪽버튼)으로 룰렛 회전 후 서서히 감속시켜 멈추게하기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class RouletteController : MonoBehaviour { public float rotAngle = 0; //회전속도 public float dampingCoefficient = 0.96f; //감쇠계수 설정 // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetMou.. 2023. 8. 5.
23/08/04 유니티짱 대각선으로 이동 멈춤 없이 타겟까지 이동(애니메이션 효과 x) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UnitychanController : MonoBehaviour { public Transform target; private bool isMoveStart = false; void Start() { } void Update() { if(this.isMoveStart) { this.transform.Translate(this.transform.forward * 1f * Time.deltaTime,Space.World); } } public void MoveS.. 2023. 8. 4.
23/08/04 유니티짱 직선으로 움직이기 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UnitychanController : MonoBehaviour { public Animator anim; float moveSpeed = 1; private bool isMove; // Start is called before the first frame update void Start() { this.anim = this.GetComponent(); //Debug.Log(this.transform.forward); //지역좌표의 앞방향 //Debug.Log(Vector3.forward); //월드좌표.. 2023. 8. 4.