I am having a few issues with a system that is acting as a basic IK solver. To test, I have setup the same code on a gameobject as well as on a group of entities.
Initially, it seems to work the same between both systems, the IK “Leg” going to the IK target in the same manner with little to no difference in calculated values. But after the target moves, the ECS-based solver seems to break away from expected calculations and shows undesired results:
(left is ECS, right is GameObject)
compassionateamusingbangeltiger
Although the equations being used to solve the simple IK systems are identical between the traditional and the ECS system (both using Unity.Mathematics), there is a big difference in how the data is handled.
As you know, in the ECS System the translation values are not calculated until end of frame (In other words, if Rotation was assigned a new value within a system, the related variables such as LocalToWorld and Position of child objects would not be updated within that same system, but in the TransformSystemGroup instead)
To account for this, I am calculating the positions and rotations within the IK system and using those values to solve the IK calculations. I have tested these calculations quite a few times and I am pretty confident they are not the issue.
That being said, the problem seems to happen after a few frames to the point where the system goes haywire. I don’t know if it is a problem others have faced and solved, but I’m looking for some guidance on how to proceed troubleshooting with this issue, and if theoretically, the values should be correct.
For the ECS System I am using the LTW values (Position and Rotation) and the system is running in LateSimulationSystemGroup.
I am using the EndSimulationEntityCommandBufferSystem and assigning rotation to the IK pivot points (no other variables being assigned)
Should I be assigning the LTW with updated values instead? I don’t have anything else updating the position, so I wouldn’t expect the following to be a problem, but could it be unsynced if I assign the Rotation and another system in the next cycle uses the LTW to update the values since I am updating the IK after the position and rotation calculations are made to the entity?
Any info might help, and I really appreciate any thought into this. I’ve been facing this issue for quite some time now.
Thanks!