Same property/method returning value's in diffrent time

Hi there i have property returning value in time

``````public class blabla
{
float a = 0.0f;
float c = 0.0f;
float b = 0.0f;

public float myProperty
{
//returning value b (myProperty)
}

void Update
{
a = myProperty;
if(a < -0.25f)
{
c = myProperty;
}

//using a and c
}
}
``````

Im using “a” 1st if “a” has -0.25f i want to start “b” from 0.0f but after reaching -0.25f value by “a”, “b” automaticly jupm on -0.25f value also.
How to start b value from 0.0f when a has -0.25f value;

OK @borkov the way you want to do this came to me overnight. I do most of my best work when asleep!

Setup an array of your values.

You want an array (let’s call the array seaArray) with all the points in your wave motion. By that I mean, and I’m going to make this more simple than your array, something like this.

``````using UnityEngine;
using System.Collections;

public class TheSeaTheSea : MonoBehaviour {

private float[] seaArray = new float[20];
private float a;
private float c;
private int aPoint;
private int cPoint;

// Use this for initialization
void Start () {
// this next bit can be done in better ways but at least you can see what I'm doing with the
// array numbers. Anyway put it in Start

seaArray[0] = 0f;
seaArray[1] = .05f;
seaArray[2] = .1f;
seaArray[3] = .15f;
seaArray[4] = .2f;
seaArray[5] = .25f;
seaArray[6] = .2f;
seaArray[7] = .15f;
seaArray[8] = .1f;
seaArray[9] = .05f;
seaArray[10] = 0f;
seaArray[11] = -0.05f;
seaArray[12] = -0.1f;
seaArray[13] = -0.15f;
seaArray[14] = -0.2f;
seaArray[15] = -0.25f;
seaArray[16] = -0.2f;
seaArray[17] = -0.15f;
seaArray[18] = -0.1f;
seaArray[19] = -0.05f;

// So the last number in the array is just before the first number.

// When the you start set aPoint = 0 and cPoint = 15 (you can change the variable names).

aPoint = 0;
cPoint = 15;

}

// Update is called once per frame
void Update () {
//then in Update

a = seaArray[aPoint];
c = seaArray[cPoint];

Debug.Log (" a = " + a + " aPoint = " + aPoint + "   and c = " + c + " cPoint = " + cPoint + "     seaArray.Length = " + seaArray.Length);

aPoint++;
cPoint++;

if (aPoint >= seaArray.Length)
aPoint = 0;

if (cPoint >= seaArray.Length)
cPoint = 0;

}
}
``````

I’ve not tested the code just typed in from my head so if it gets errors probably a typo, just let me know how you get on.

EDIT: Remember never try and be smart and type in untested code! Just tested that and it’s full of errors. Fixed my idiot code and re-posted above!