- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
- using System.Collections;
-
- public class CourseiTweenLine : MonoBehaviour {
- public GameObject target;
- public GameObject ballPrefab;
-
- private Vector3[] paths=new Vector3[3];
- // Use this for initialization
- void Start () {
-
- }
-
- // Update is called once per frame
- void Update () {
- Ray ray = camera.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit))
- {
- if (hit.transform.gameObject.tag == "tile")
- {
- iTween.MoveUpdate(target, new Vector3(hit.point.x, 0.1f, hit.point.z), 0.1f);
-
- if (Input.GetMouseButtonDown(0))
- {
- GameObject go = (GameObject)Instantiate(ballPrefab, new Vector3(0, 0, 0), Quaternion.identity);
- paths[0] = new Vector3(0, 0, 0);
- paths[2] = hit.point;
- paths[1] = new Vector3(hit.point.x / 2, 3f, hit.point.z / 2);
- //这几个参数要记
- iTween.MoveTo(go, iTween.Hash("path", paths, "movetopath", true, "orienttopath", true, "time", 1, "easetype", iTween.EaseType.linear));
- Destroy(go, 1.8f);
- }
- }
- }
- }
- private void OnDrawGizmos()
- {
- iTween.DrawLine(paths, Color.blue);
- iTween.DrawPath(paths, Color.red);
- }
- }
复制代码 |
|