EngediKimHyeYoung / Unity

0 stars 0 forks source link

상자 점프하기 - Player.cs #1

Open EngediKimHyeYoung opened 2 years ago

EngediKimHyeYoung commented 2 years ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player : MonoBehaviour { protected float jump_speed = 5.0f;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    if(Input.GetMouseButtonDown(0))
    {
        this.GetComponent<Rigidbody>().velocity = Vector3.up * this.jump_speed;
    }
}

}

EngediKimHyeYoung commented 2 years ago

https://docs.unity3d.com/kr/530/ScriptReference/Input.GetMouseButtonDown.html

EngediKimHyeYoung commented 2 years ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player : MonoBehaviour {

protected float jump_speed = 5.0f;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

    if (Input.GetMouseButtonDown(0))
    {
        this.GetComponent<Rigidbody>().velocity = Vector3.up * this.jump_speed;
    }

}

private void OnMouseDown()
{
    Debug.Log("OnMouseDown");
}
private void OnMouseOver()
{
    //bug.Log("OnMouseOver");
}
private void OnMouseUp()
{
    Debug.Log("OnMouseUp");
}

}

EngediKimHyeYoung commented 2 years ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player : MonoBehaviour {

protected float jump_speed = 5.0f;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        this.GetComponent<Rigidbody>().velocity = Vector3.up * this.jump_speed;
    }

    if (Input.GetKey("up"))
    {
        print("up");
    }
    if (Input.GetKey("down"))
    {
        //print("down");
        Debug.Log("down");
    }
}

private void OnMouseDown()
{
    Debug.Log("OnMouseDown");
}
private void OnMouseOver()
{
    //bug.Log("OnMouseOver");
}
private void OnMouseUp()
{
    Debug.Log("OnMouseUp");
}

}

EngediKimHyeYoung commented 2 years ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player : MonoBehaviour {

protected float jump_speed = 5.0f;
public bool is_landing = false;
// Start is called before the first frame update
void Start()
{
    this.is_landing = false;
}

// Update is called once per frame
void Update()
{
    if (this.is_landing)
    {
        if (Input.GetMouseButtonDown(0))
        {
            this.is_landing = false;
            this.GetComponent<Rigidbody>().velocity = Vector3.up * this.jump_speed;
        }
    }
}
private void OnCollisionEnter(Collision collision)
{
    this.is_landing = true;
    Debug.Log("collision");
}

}

EngediKimHyeYoung commented 2 years ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player : MonoBehaviour {

protected float jump_speed = 11.0f;
public bool is_landing = false;
// Start is called before the first frame update
void Start()
{
    this.is_landing = false;
}

// Update is called once per frame
void Update()
{
    if (this.is_landing)
    {
        if (Input.GetMouseButtonDown(0))
        {
            this.is_landing = false;
            this.GetComponent<Rigidbody>().velocity = Vector3.up * this.jump_speed;
            //Debug.Break();
        }
    }
}
private void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.tag == "Floor")
    {
        this.is_landing = true;
        //Debug.Log("collision");
    }
}

}