유니티 기초/복습

[수업과제] 표창 던지기 - 복습

다모아 2023. 8. 2. 01:01

ShurikenController

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);
    }
}

너무 빨라서 인식을 못함..Rotate(0,0,5)

 

Rotate(0,0,3)