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);
}
}
AD
最新推荐文章于 2023-05-10 15:56:53 发布