anonymous No title
No License C#
2020年11月04日
Copy Clone
public class PlayerController : MonoBehaviour
{
    Rigidbody2D rigid2D;
    Animator animator;
    float jumpForce = 680.0f;
    float walkForce = 30.0f;
    float maxWalkSpeed = 2.0f;
    GameObject player;


    // Start is called before the first frame update
    void Start()
    {
        this.rigid2D = GetComponent<Rigidbody2D>();
        this.animator = GetComponent<Animator>();
        this.player = GameObject.Find("cat");
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            this.rigid2D.AddForce(transform.up * this.jumpForce);
        }

        int key = 0;
        if (Input.GetKey(KeyCode.RightArrow)) key = 1;
        if (Input.GetKey(KeyCode.LeftArrow)) key = -1;

        float speedx = Mathf.Abs(this.rigid2D.velocity.x);

        if (speedx < maxWalkSpeed)
        {
            this.rigid2D.AddForce(transform.right * key * this.walkForce);
        }

        if (key != 0)
        {
            transform.localScale = new Vector3(key, 1, 1);

        }
        this.animator.speed = speedx / 2.0f;


        //プレイヤーの位置を取得
        Transform playerPos = this.player.transform;
        //座標を取得
        Vector3 pos = playerPos.position;

        if (pos.x < -3f)
        {
            pos.x = 3f;
            playerPos.position = pos;
        }
        else if (pos.x > 3f)
        {
            pos.x = -3f;
            playerPos.position = pos;
        }

    }

    void OnTriggerEnter2D(Collider2D other)
    {
        UnityEngine.Debug.Log("ゴール");
        SceneManager.LoadScene("ClearScene");
    }

}
public class PlayerController : MonoBehaviour
{
    Rigidbody2D rigid2D;
    Animator animator;
    float jumpForce = 680.0f;
    float walkForce = 30.0f;
    float maxWalkSpeed = 2.0f;
    GameObject player;


    // Start is called before the first frame update
    void Start()
    {
        this.rigid2D = GetComponent<Rigidbody2D>();
        this.animator = GetComponent<Animator>();
        this.player = GameObject.Find("cat");
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            this.rigid2D.AddForce(transform.up * this.jumpForce);
        }

        int key = 0;
        if (Input.GetKey(KeyCode.RightArrow)) key = 1;
        if (Input.GetKey(KeyCode.LeftArrow)) key = -1;

        float speedx = Mathf.Abs(this.rigid2D.velocity.x);

        if (speedx < maxWalkSpeed)
        {
            this.rigid2D.AddForce(transform.right * key * this.walkForce);
        }

        if (key != 0)
        {
            transform.localScale = new Vector3(key, 1, 1);

        }
        this.animator.speed = speedx / 2.0f;


        //プレイヤーの位置を取得
        Transform playerPos = this.player.transform;
        //座標を取得
        Vector3 pos = playerPos.position;

        if (pos.x < -3f)
        {
            pos.x = 3f;
            playerPos.position = pos;
        }
        else if (pos.x > 3f)
        {
            pos.x = -3f;
            playerPos.position = pos;
        }

    }

    void OnTriggerEnter2D(Collider2D other)
    {
        UnityEngine.Debug.Log("ゴール");
        SceneManager.LoadScene("ClearScene");
    }

}
anonymous
Anonymous
2021年04月29日
Meds information for patients. Short-Term Effects. <a href="https://toplyrica.top">how to purchase pregabalin without a prescription</a> in Canada Best about meds. Read now.
anonymous
Anonymous
2021年04月30日
how to get cialis prescription online <a href="https://mycialistabs.com/">discount cialis</a> cialis usa
anonymous
Anonymous
2021年05月02日
how long before sex should you take cialis <a href="https://toptadalafiltabs.com/">cialis viagra</a> cialis 20 milligram
anonymous
Anonymous
2021年05月04日
how to write rhetorical analysis essay <a href="https://topessaywriterfas.com/">cheap essay writing services</a> how to write a 250 word essay about yourself
anonymous
Anonymous
2021年05月06日
essay service tips <a href="http://writemyessayslfd.com/">help writing college essay</a> best essay writihg service
anonymous
Anonymous
2021年05月07日
viagra cialis <a href="https://mrviagrashop.com">natural alternative to viagra</a> viagra alternative
anonymous
Anonymous
2021年05月07日
ingrediants in viagra <a href="https://mysildenafilkr.com/">sildenafil para que sirve</a> chinese herb viagra
anonymous
Anonymous
2021年05月11日
Drug prescribing information. Generic Name. <a href="https://prednisone4u.top">order cheap prednisone without dr prescription</a> in US. Actual about medicine. Get information now.
anonymous
Anonymous
2021年05月12日
scrum master resume <a href="http://coverletterforresumetop.com/">best way to make a resume</a> resume wizard
anonymous
Anonymous
2021年05月12日
cialis manufacturer coupon <a href="http://tadalafilled.com/">tadalafil coupon</a> what cialis
anonymous
Anonymous
2021年05月13日
cover page for resume <a href="https://writingacoverletteronline.com/">cover letter for employment</a> first job resume
anonymous
Anonymous
2021年05月14日
buy sildenafil <a href="https://edviagramaster.net/">viagra alternative</a> alternatives to viagra
anonymous
Anonymous
2021年05月15日
female viagra walgreens <a href="https://sildenafilviagratop.com">best herbal viagra</a> womens viagra
anonymous
Anonymous
2021年05月15日
cialis manufacturer coupon <a href="https://cialisortadalafil.com/">tadalafil coupon</a> what cialis
anonymous
Anonymous
2021年05月17日
canadian pharmacy ezzz cialis <a href="https://topcialistabs.com/">cialis strength</a> cialis vs. viagra recreational use
anonymous
Anonymous
2021年05月19日
<a href="https://edtadalafilhot.net/">https://edtadalafilhot.net/</a>
anonymous
Anonymous
2021年06月02日
Drug information for patients. What side effects? <a href="https://imodium4u.top">generic imodium no prescription</a> in USA Best news about drugs. Get now.
anonymous
Anonymous
2021年08月31日
<a href="https://domalech.ru/">trazodone for dogs eye drops</a>
anonymous
Anonymous
2021年09月05日
Medicines prescribing information. What side effects can this medication cause? <a href="https://lisinopril2020.top">can you get lisinopril</a> in Canada Some news about medicament. Get information here.