Can UpdateInstanceTransform affect the Custom Float of an ISM? Video:

This is the only line im changing, and this is causing a change in the Custom Float in the material. How is this possible?

ISM_Units->UpdateInstanceTransform(CurUnit, UnitTransform, true, true);

At first i thought it was something i have done somewhere in the code.
After cutting it to pieces and debugging back and forth i realized it couldn’t be me.

So i started commenting out specific lines.
And realized this one is the “offending one”.

Im not changing anything else. Just that line of code and it affects the custom data value. Why would this cause this issue?

Also tried this code, just to make sure its not the transform freaking out, you can see im using the same transform the plane instance has, so its not changing anything, and it still seems to affect the custom data of the instance.

Why is this happening and how can i fix this?

Hi, does it happen if you add “ISM_Units->MarkRenderStateDirty();” instead of the UpdateInstanceTransform()? It may be that the Update is highlighting the issue from something else.

2 Likes

Thanks for trying to help.

Found the solution. And i think its important that i write this here so that if others come accross the same issue they will know.

The problem is in the vinterp.
Apparently if you make vinterp and the 2 Vectors are equal. You will bug the instance floats. I dont know exactly why this is.

I start the checkpoints array with the current tile of the unit. Apparently thats a problem.

I debugged it as best as i could. I have no explanation for it but it fixes it if i add +FVector(10.f,0,0) to the first checkpoint always, to make sure its not exactly the same as your current tile.

I spent some hours on this. It was very hard to debug because it doesnt make sense.

TLDR: Vinterping to the Location you are in can temporarily bug your instance floats. So like:
FVector AdvanceLocation = FMath::VInterpConstantTo(FVector(4700.f, 6000.f, 0.f), FVector(4700.f, 6000.f, 0.f), DeltaTime, 10); This will bug the color.

Actually the bug is not due to the Vinterp. I found out that it happens everytime you move an instance on the same exact location the instance is currently.

I made a little test project that shows this.

TestBugISMMaterial.rar (1.8 MB)

1 Like

Very Strange! - I’m not quite understanding why it happens - but if you add a very small amount to the location of the transform it works ok:

1 Like

It doesn’t happen in 5.4 using the same logic, so it looks like it’s been fixed anyway.

Maybe a work-around is to test the transform first to see if it’s identical and only update when it’s not?

1 Like

This is what i tried first in C++. So everytime i had to update the transform, i checked if its not the same, though sometimes you are updating the transform only for the scale and the rotation, and changing those only still causes the bug.

Instead of using the function UpdateInstanceTransform. I create another function wrapper that refreshes the CustomDataFloats.

I also tried the translation, yesterday though it seemed it failed sometimes I dont know exactly why.
Thanks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.