ShurikenController
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShurikenController : MonoBehaviour
{
public float moveSpeed;
private float startPos;
private float endPos;
private float distanceY;
private float dampingCoeffient = 0.96f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetMouseButtonDown(0))
{
this.startPos = Input.mousePosition.y;
}
else if(Input.GetMouseButtonUp(0))
{
this.endPos = Input.mousePosition.y;
this.distanceY = endPos - startPos;
moveSpeed = distanceY / 1000f;
}
this.gameObject.transform.Translate(0, moveSpeed, 0, Space.World);
//감소
moveSpeed *= dampingCoeffient;
this.gameObject.transform.Rotate(0, 0, 5);
}
}



'유니티 기초 > 복습' 카테고리의 다른 글
챕터6 ClimbCloud [미완] - 복습 (0) | 2023.08.04 |
---|---|
챕터 5 고양이 탈출 복습 - [완] (0) | 2023.08.04 |
챕터5 고양이탈출 - CatEscape - 복습 (0) | 2023.08.02 |
자동차 스와이프 Swipe Car - 복습 (0) | 2023.08.02 |
유니티 복습 (0) | 2023.08.01 |