纳金网
标题:
iTween学习笔记之抛物线代码
[打印本页]
作者:
狂风大尉
时间:
2014-6-28 01:43
标题:
iTween学习笔记之抛物线代码
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);
}
}
复制代码
作者:
xkjoy
时间:
2014-6-28 01:52
C#我喜欢!JS看着就头疼啊
作者:
hyui
时间:
2014-6-28 02:21
Thanks for sharing this !
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5