Obi Official Forum
Setting instances of rope mesh renderer at runtime - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Setting instances of rope mesh renderer at runtime (/thread-2960.html)



Setting instances of rope mesh renderer at runtime - luvjungle - 28-05-2021

Hi! 
I want to constantly changle length with cursor and adjust instances amount at runtime. But every time when I change instances amount, my rope teleports to some point and becomes straight, then cursor updates it and rope teleports back and becomes normal.
Is it a bug or setup issue or anything else?


RE: Setting instances of rope mesh renderer at runtime - luvjungle - 30-05-2021

Managed to fix it like this: any time I need to change instances amount, I wait till Initialization in UniTask
Code:
    async UniTaskVoid SetInstances(int parts)
    {
        await UniTask.Yield(PlayerLoopTiming.Initialization, this.GetCancellationTokenOnDestroy());
        meshRend.Instances = parts;
    }

I tried to set instances in LateUpdate() with no luck. Anyway, I use Unitask in this project.