When I increase the length of my chain in the awake function in the final construction sometimes it gets stuck and if I move it it is as if it was fixed at that point where it got stuck, this does not happen in the editor,it only happens occasionally when I open the project
Is it because from awake it starts to increase the length?
Is it because from awake it starts to increase the length?
Code:
void Awake()
{
instance = this;
chainShort = true;
rope = GetComponent<ObiRope>();
//Debug.Log("rest" + rope.restLength);
}
// Update is called once per frame
void Update()
{
if (chainShort == true)
{
IncreaseLenght(1);
}
if (chainLarge == true)
{
IncreaseLenght(-1);
}
}
internal void IncreaseLenght(float normX)
{
//Debug.Log("increse lenght");
//Debug.Log(rope.restLength);
if (normX == 1)
{
if (rope.restLength > min)
{
for (int i = 0; i < cursor.Length; ++i)
{
cursor[i].ChangeLength(rope.restLength - speed * Time.deltaTime);
}
}
else { chainShort = false; /*Debug.Log("rest" + rope.restLength);*/ }
}
if (normX == -1)
{
if (rope.restLength < max)
{
for (int i = 0; i < cursor.Length; ++i)
{
cursor[i].ChangeLength(rope.restLength + speed * Time.deltaTime);
}
}
else { chainLarge = false; }
}
}