A ninja-update here with a tantalising bit of code you may or may not be interested in.
The water / tidal effect script from the previous post.
It could actually be used for anything requiring an up/down motion (....no comment) - e.g, moving platforms or such.
Enjoy, and use it in the spirit in which it was created:
using UnityEngine;
using System.Collections;
public class TidalEffect : MonoBehaviour {
void Start () {
initial_y = gameObject.transform.position.y;
}
public float upperBound;
public float speed;
private float initial_y;
float current = 0.0f;
int direction = 1;
void Update () {
current = Time.deltaTime * speed * direction;
Vector3 move = gameObject.transform.position;
move.y += current;
if (move.y > initial_y + upperBound)
{
direction *= -1;
move.y = initial_y + upperBound;
}
if (move.y < initial_y - upperBound)
{
direction *= -1;
move.y = initial_y - upperBound;
}
gameObject.transform.position = move;
}
}
1 comment:
no commment... LOL!
Post a Comment