Obi Official Forum

Full Version: Setting instances of rope mesh renderer at runtime
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.