Manipulating entity-bodies

Once the entity is assigned as a physics-simulated body, the engine core transfers entity management powers to the Box2D simulator. For this reason, every manipulation procedure which involves moving and rotating the entity, must pass through the simulator engine.

We can move basic non-physics-managed entities by simply changing their current position, but for physics-managed entities it is necessary to apply impulses or set linear velocities if we want to move entities around.

The ETHPhysicsController@ reference object encapsulates a b2Body object which is used to manipulate body properties.

Retrieving the physics controller of an entity is very simple, all we need to do is call ETHEntity::GetPhysicsController:

void ETHEntityCallback_character(ETHEntity@ thisEntity)
{
	ETHPhysicsController@ controller = thisEntity.GetPhysicsController();

	// if the returned value is null, it means thisEntity doesn't have a physics body
	if (controller is null)
		return;

	// move the character to the right
	controller.SetLinearVelocity(vector2(4.0f, 0.0f));
}

Browse all ETHPhysicsController methods in the API reference pages.