본문 바로가기

KDT/유니티 기초22

23/08/03 애니메이션 방향 전환 및 점프 연습 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class HeroController : MonoBehaviour { private Animator anim; public Rigidbody2D rBody2D; public float jumpForce; public float moveSpeed; private float moveForce = 1f; private bool isJump = false; // Start is called before the first frame update void Start() { this.anim = this.GetComponent(); this.. 2023. 8. 3.
23/08/02 키보드로 인풋 받아 이동하기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class HeroController : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //키보드 좌우 인풋을 받아 -1,0,1 출력 float h = Input.GetAxisRaw("Horizontal"); //-1,0,1 //h; 방향 의미하는 값 Debug.LogFormat("===>{0}", (int)h); //좌우반전 스케일의 X값을 -1로 한다. 이때 Y.. 2023. 8. 3.
23/08/01 [수업과제] 표창 던지기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ShurikenController : MonoBehaviour { float rotSpeed = 0; float moveSpeed = 0; float dampingCoeffcient = 0.96f; //감쇠계수 private Vector3 startPos; //down 했을때 위치 // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //마우스 스와이프 //마우스 왼쪽 버튼을 눌렀다면 if.. 2023. 8. 1.
23/08/01 SwipeCar using System.Collections; using System.Collections.Generic; using UnityEditor.Tilemaps; using UnityEngine; public class CarController : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //매프레임마다 호출됨 //마우스 왼쪽 버튼을 눌렀다면 if (Input.GetMouseButtonDown(0)) { Debug.Log("왼쪽버튼 눌림!"); //원점으로 게임 오브젝트를 이동하자 Debug.Log(this); //.. 2023. 8. 1.