Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two components I'd like to connect them to each other. 1. PhysicalComponent - containing rigid body(position, rotation, velocity) and is holding body from physics engine. 2. GraphicsComponent - onscreen representation(position too, rotation too).

I'd like to sync this components, how to do it? 1. Read position, and rotation in GraphicsComonent from Physical comopnent. 2. Add one more component that sync them.

But problem is that I want to change on screen representation( other class such as PositionInerpolator do it, and it can work only with GraphicsComponent), and it must change physical body position. Is it a bad idea, and I must move physical body directly? Thanx in advance.

share|improve this question
Perhaps the graphics component should have or contain a interpolation component, its not really game logic, and assuming it is purely being used for a smoothened movement (visual) effect, why not encapsulate it. Therefore, all that needs to be passed is the position from the physical to the graphics, as to how, hopefully that will be answered. – dcousens Dec 25 '11 at 21:30
up vote 2 down vote accepted

The way I handle it in my engine is to call a FixedUpdate() on all components when the fixed timestep physics frame ends, when the PhysicsComponent receives FixedUpdate() it will query for the rigid body position from the physics engine, if it finds a change in position since the last update it sends a message to itself saying its position has changed, and includes the new position in the message. This is a message type the RenderComponent listens for. When the RenderComponent receives the position it updates the position of the render mesh.

You're free to see the exact code for yourself if you would like, the engine is open-source, and is built on an Entity->Components hierarchy:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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