zoukankan      html  css  js  c++  java
  • sine曲线向前运动

    using UnityEngine;
    using System.Collections;
    
    public class sineWork : MonoBehaviour {
    
        float verticalSpeed = 5.0f;                    //Vertical speed
        float verticalDistance = 6.0f;                //Vertical distance
        
        float horizontalSpeed  = 2;                    //Horizontal speed
        
        float offset = 0.0f;                        //Vertical offset
        float originalPos = 0;                        //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 = (1 + 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;
        }
    }
  • 相关阅读:
    柱状图最大的矩形
    单词搜索
    最小覆盖子串
    颜色分类
    编辑距离
    X的平方根
    二进制求和
    最大子序和
    N皇后
    java8-14-时间API
  • 原文地址:https://www.cnblogs.com/softimagewht/p/3745811.html
Copyright © 2011-2022 走看看