AD

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

public class Jump : MonoBehaviour
{
    CharacterController controller;
    float angle = 5;
    float speed = 5;
    Animator animator;  
    void Start()
    {
        animator = GetComponent<Animator>();
        controller = GetComponent<CharacterController>()
    }

   
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        int layer = LayerMask.GetMask("Floor");
        if (Physics.Raycast(ray,out hit,100,layer))
        {
            transform.LookAt(hit.point);
        }
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Vector3 dir = new Vector3(h,0,v);
        if (h == 0 && v == 0)
        {
            animator.SetBool("Move", false);
        }
        else
        {
            animator.SetBool("Move", true);

        }
        //if (h>0&&v>0)
        //{
        //       animator.SetInteger("Move",1);

        //}
        //if (h == 0 && v == 0)
        //{
        //    animator.SetInteger("Move",0);

        //}
        //if (h <0 && v<0)
        //{
        //    animator.SetInteger("Death", -1);

        //}
        dir = Quaternion.Euler(0,45,0)*dir;
        // transform.position += new Vector3(h*0.1f,0,v*0.1f);
        controller.Move(dir*0.1f);
        animator.SetTrigger("Death");

        //if (Input.GetKeyDown(KeyCode.Space))
        //{
        //    // animator.SetBool("Jump",true);
        //    animator.SetTrigger("Jump");
        //}
        //if (Input.GetKey(KeyCode.W))
        //{
        //    gameObject.transform.Translate(Vector3.forward * speed * Time.deltaTime);
        //}
        //if (Input.GetKey(KeyCode.S))
        //{
        //    gameObject.transform.Translate(Vector3.back * speed * Time.deltaTime);
        //}
        //float mx = Input.GetAxis("Mouse X");
        //float my = Input.GetAxis("Mouse Y");
        //transform.Rotate(Vector3.up,mx);



    }
}
           

       


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值