首页 > 其他 > 详细

u3d人物控制

时间:2019-02-01 16:57:25      阅读:261      评论:0      收藏:0      [点我收藏+]
//https://blog.csdn.net/Htlas/article/details/79188008
//人物移动 http://gad.qq.com/article/detail/289212
//mesh  山丘地形 http://gad.qq.com/article/detail/289108

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Cube : MonoBehaviour {
    public EasyTouchMove touch;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        //获取horizontal 和 vertical 的值,其值位遥感的localPosition
        float hor = touch.Horizontal;
        float ver = touch.Vertical;
 
        Vector3 direction = new Vector3(hor, 0, ver);
 
        if(direction!= Vector3.zero) {
            //控制转向
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(direction),Time.deltaTime*10);
            //向前移动
            transform.Translate(Vector3.forward * Time.deltaTime * 5);
        }
	}
}

//2D碰撞检测
// Collider2D[] col = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));
 
// if(col.Length > 0)
// {
//     foreach(Collider2D c in col)
//     {
//          //do what you want
//     }
// }

  

u3d人物控制

原文:https://www.cnblogs.com/slqt/p/10346193.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!