sine曲线向前运动
2024-09-05 00:48:21
using UnityEngine;
using System.Collections; public class sineWork : MonoBehaviour { float verticalSpeed = 5.0f; //Vertical speed
float verticalDistance = 6.0f; //Vertical distance float horizontalSpeed = ; //Horizontal speed float offset = 0.0f; //Vertical offset
float originalPos = ; //Original y position Vector3 nextPos = new Vector3(); //Stores the next position
Vector3 startingPos; // Use this for initialization
void Start () { } // Update is called once per frame
void Update () { //Get current position
nextPos = this.transform.position; //Calculate new vertical position
offset = ( + Mathf.Sin(Time.time * verticalSpeed)) * verticalDistance / 2.0f;
nextPos.y = originalPos + offset; //Calculate new horizontal position
nextPos.x -= horizontalSpeed * Time.deltaTime; //Apply new position
this.transform.position = nextPos;
}
}
最新文章
- [转]java web简单权限管理设计
- 如何在maven中添加jar包
- TCP 状态机
- 在主方法中定义一个大小为50的一维整型数组,数组i名为x,数组中存放着{1,3,5,…,99}输出这个数组中的所有元素,每输出十个换一行
- windows休眠命令
- javascript实例学习之八——无缝切换效果
- javascript 小日历
- oracle 实例名和服务名以及数据库名区别
- No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
- [LeetCode] 200. Number of Islands 解题思路
- 字符设备驱动4: ioremap
- em,strong,b,i的区别
- JS中使用正则表达式替换对象里的大小写
- [物理学与PDEs]第2章第2节 粘性流体力学方程组 2.6 一维粘性热传导流体动力学方程组
- Linux下的常见压缩解压缩命令
- GIF录制
- 【转载】 pytorch之添加BN
- vue教程1-08 交互 get、post、jsonp
- vue.js 过渡&;动画
- JUC锁之 框架