Пример #1
0
    void Update()
    {
        Vector3    pos           = m_Water.GetHeightOffsetAt(transform.position);
        Vector3    norm          = m_Water.GetNormalAt(transform.position, 1.0F);
        Quaternion normalRotated = Quaternion.identity;

        normalRotated.SetFromToRotation(Vector3.up, norm);

        // interpolate a little to get smoother floating
        transform.rotation = Quaternion.Slerp(transform.rotation, normalRotated, Time.deltaTime * 4.0f);
        transform.position = Vector3.Lerp(transform.position, pos, Time.deltaTime * 4.0f);
    }
Пример #2
0
 public override float WaveFunction(Vector3 worldPoint)
 {
     return((water.GetHeightOffsetAt(worldPoint).y - transform.position.y) * invWaveAmplitude);
 }