1
\$\begingroup\$

In the given flow, the character is the parent entity, gun is child of character and bullet is child of gun. I've got a component called NodeComponent which has the storage of child entities and a NodeSystem that iterate the children then update its position relative to its parent. The problem is when the iteration reach to the bullet, it takes some time to update the bullet position. So when I move the parent the bullet is noticeable. How do I handle the parent-child relationship transformation without losing or slowing down the update from top to bottom?

Character >>
             Gun >>
                    Bullet
\$\endgroup\$
  • \$\begingroup\$ Is the bullet inside the gun? \$\endgroup\$ – Vaillancourt Jul 26 '16 at 17:51
  • \$\begingroup\$ yes, it was. .. \$\endgroup\$ – ronscript Jul 26 '16 at 18:06
  • \$\begingroup\$ Once the gun shoots the bullet, there is no longer a parent-child relationship. The gun should have all the information to spawn the bullet, but the bullet should be a child of the main node of your environment, not be a child of the gun. \$\endgroup\$ – Vaillancourt Jul 26 '16 at 18:08
  • \$\begingroup\$ hmmm I can't understand why the bullet should be the child of main node? \$\endgroup\$ – ronscript Jul 26 '16 at 18:16
  • 1
    \$\begingroup\$ Then I don't really understand the question. In real life, once you shoot a bullet with a gun, the bullet is no longer linked to the gun, in any way. It's free. It's living its own life! It's as free as the player. Once I hit the trigger, the bullet is gone and even though I move gun, there is no way I can influence the trajectory. \$\endgroup\$ – Vaillancourt Jul 26 '16 at 18:21
2
\$\begingroup\$

The relationship between the Gun and the Bullet is purely 'spawner/spawned'. It's not parent-child.

In real-life, when you shoot a bullet with a gun, both objects are no longer linked: you can move the gun as you want, once the bullet is out of the barrel, there's nothing you can do to change its trajectory.

So in your case, you should make the bullet as a sibling of the player, and not a child of the gun.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.