Hello,
I am currently developing a hitbox/hurtbox system. The first thing I need to get right is having entity with physic bodies matching the character’s animation.
Now, animation doesn’t have a DOTS equivalent just yet, so I am currently using a hybrid system. GameObject handles the animation, the rest is handled by ECS.
Here is a challenge, because I need to use LateUpdate to get the position of the Character Bones (like the Head or the arms), write that on a component, and then have a system use the data of the component to move the colliders around.
There is an issue - the ECS transform system runs before LateUpdate. So whatever I do, it has to be after the TransformSystem.
I tried updating LocalTransform, but it updates one frame later.
I tried updating TransformAspect, but the same thing happens (LocalPosition and WorldPosition both update one frame late)
I then went with something that usually works, which is just creating a new LocalToWorld and replacing that. Then the movement matches the position perfectly.
However, the colliders are not uniform in scale. So when I create a new LocalToWorld, the position and rotation update, but the collider is wrong scale (1,1,1). I tried many different ways to keep the scale or reset it, but it doesn’t work.
My question is two fold:
-
What is the correct way to go about this? Remember that I must get the info in LateUpdate, as I’m following the animations.
-
If I do have to create a new LocalToWorld, then how do I keep the scale? How do I create a float4x4 with rotation, position, and scale?
Thanks for the help! Looking forward to the answer, as this is a very common situation in any action game, and the reply may benefit future people working on the same thing.
Cheers.
edit: I have found a partial solution, but the problem is still there - I still haven’t found a way to correctly update instantly the position of an entity, to follow the bones of an animation of a gameobject. I still need insight to solve this. Details in the latest post.