您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

25 行
518 B

using System;
using UnityEngine;
using System.Collections;
public class Oscilate : MonoBehaviour
{
public float speed = 0.1f;
public Vector2 start;
public Vector2 stop;
private float elapsed;
Vector3 startPosition;
void Start()
{
startPosition = transform.position;
}
void Update()
{
elapsed += speed * Time.deltaTime;
float l = Mathf.Sin(elapsed);
transform.position = Vector2.Lerp(startPosition, l > 0 ? start : stop, Math.Abs(l));
}
}