Adding a child transform with its own collider

I’ve added a child node to my enemy to use it as attacking area See the next screenshot:

But in game, the child doesn’t move with its parent as you see in the next screenshot (I’ve changed the TCastleTransform by a TCastleBox):

If I remove the child’s collider and rigidbody it works, but then the zombi’s collider seems to be bigger because the child cube pushes the player (?!).

Is it a bug or am I doing something wrong?

Hm, this definitely seems like a bug – can you submit a testcase for me to play around and reproduce / fix?

To be clear, it should work as you expect – moving the TCastleTransform should move the children, along with children’s colliders naturally. I did use this technique many times (like in examples/mobile/two_cars/ where cars, with their colliders, move).

Note that we had a bug around this in earlier engine versions, but it was fixed around August 2024 (around this post). So if you’re using an older version of the engine, please upgrade and retest.

I don’t understand this issue clearly here (I don’t see zombie collider on the 1st screenshot), but feel welcome to submit a testcase showing it too.

I’ve updated to yesterday’s snapshot and it still happens.

I’ve made a small example that reproduces the issue. I’ve uploaded here*. I explain things in the README.md file so please read it.


[*] It was the first place I’ve found. If the link doesn’t work assume I’ve clean the website. :stuck_out_tongue:

1 Like

I think I’ve found a possible culprit: the Kraft physics engine. I’ll try to explain.

In my code I use LinearVelocity to move the characters as Translation didn’t seem to work. I use a finite state machine so when moving or jumping I update LinearVelocity in each Update and I set it to zero when it enters in the Idle state but not update it.

When I’ve added rotation I found an issue: if I update Direction in each Update, even if it doesn’t change, the character doesn’t move smoothly but its speed is random as if the ground were wrinkled and it hits when sliding. So I added a check to know if direction changed before the update and now characters move as they should.

My guess is that everytime Direction is assigned, Kraft updates it’s momentum or velocity to zero even if it shouldn’t change. Also everytime a transform changes it’s physics state, Kraft updates its childs physics state.

Diving a little in the code I’ve found that CGE checks if rotation changes before to assign the new one; maybe RotationFromDirectionUp introduces some round-errors that makes PerfectlyEquals to fail when assigning the rotation but those round-errors are so small after applying Kraft physics that rotation doesn’t change?

Does it has sense?