using UnityEngine;
using System.Collections;
public class TileShake : MonoBehaviour {
private float maxY = 1f;
private float mixY = -1f;
private int direction = 1;
private int moveSpeed = 3;
private int moveRightSpeedX = 3;
void Start () {
}
void FixedUpdate () {
rigidbody2D.velocity = new Vector2(moveRightSpeedX, 0);
Vector3 tmpVec = transform.position;
tmpVec.y += direction * moveSpeed * Time.fixedDeltaTime;
transform.position = tmpVec;
if (transform.position.y > maxY)
{
direction = -1;
}
else if (transform.position.y < mixY)
{
direction = 1;
}
}
}
Unity物体上下曲线运动
最新推荐文章于 2024-06-23 01:29:45 发布