查看: 4273|回复: 2
打印 上一主题 下一主题

[其他] iTween学习笔记之抛物线代码

[复制链接]

711

主题

10

听众

5805

积分

高级设计师

Rank: 6Rank: 6

纳金币
2954
精华
3

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2014-4-30 02:47:05 |只看该作者 |倒序浏览
  1. using UnityEngine;
  2. using System.Collections;

  3. public class CourseiTweenLine : MonoBehaviour {
  4.     public GameObject target;
  5.     public GameObject ballPrefab;

  6.     private Vector3[] paths=new Vector3[3];
  7.     // Use this for initialization
  8.     void Start () {
  9.      
  10.     }
  11.      
  12.     // Update is called once per frame
  13.     void Update () {
  14.         Ray ray = camera.ScreenPointToRay(Input.mousePosition);
  15.         RaycastHit hit;
  16.         if (Physics.Raycast(ray, out hit))
  17.         {
  18.             if (hit.transform.gameObject.tag == "tile")
  19.             {
  20.                 iTween.MoveUpdate(target, new Vector3(hit.point.x, 0.1f, hit.point.z), 0.1f);

  21.                 if (Input.GetMouseButtonDown(0))
  22.                 {
  23.                     GameObject go = (GameObject)Instantiate(ballPrefab, new Vector3(0, 0, 0), Quaternion.identity);
  24.                     paths[0] = new Vector3(0, 0, 0);
  25.                     paths[2] = hit.point;
  26.                     paths[1] = new Vector3(hit.point.x / 2, 3f, hit.point.z / 2);
  27.                     //这几个参数要记
  28.                     iTween.MoveTo(go, iTween.Hash("path", paths, "movetopath", true, "orienttopath", true, "time", 1, "easetype", iTween.EaseType.linear));
  29.                     Destroy(go, 1.8f);
  30.                 }
  31.             }
  32.         }
  33.     }
  34.     private void OnDrawGizmos()
  35.     {
  36.         iTween.DrawLine(paths, Color.blue);
  37.         iTween.DrawPath(paths, Color.red);
  38.     }
  39. }
复制代码
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

无效楼层,该帖已经被删除
hyui    

1

主题

2

听众

6671

积分

高级设计师

Rank: 6Rank: 6

纳金币
2715
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2014-4-30 03:49:27 |只看该作者
time to learn fro others code)))
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-23 07:33 , Processed in 0.214441 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部