This project has moved and is read-only. For the latest updates, please go here.

Non-colliding zero-mass body

Topics: Developer Forum
Jan 20, 2013 at 4:52 PM
Edited Jan 20, 2013 at 4:56 PM

I seem to be unable to find a way to set up the body of my light-sources.

Here's what I want to do:
The player is a spaceship with a dynamic body type.
I want to attach lamps to the spaceship that affect nothing physically, but are still moved with the player (rotation and position, basically)

The closest I've gotten is having LightSources with very low mass, but it does not feel like a good solution (and the player seems to still rotate in a more sluggish fashion). I set body.Enabled = false by default, but when it is attached to the player, I do the following:

	testLight.body.Enabled = true;
	testLight.body.CollidesWith = Category.None;
	JointFactory.CreateWeldJoint(world, player.body, testLight.body, player.body.Position);

1. Is there a nice solution to this?
2. How does giving light-sources Farseer Physics bodies affect performance?

Jan 22, 2013 at 12:08 AM

I depends on what you need.

If you need the lights to break off, you create something like a weld joint. For anything else, I have 2 suggestions:

1. Use sensors if you don't need collision reactions or any other interaction with the world. They simply detect collisions, but since they do not move, you will have to move them manually by setting their position on each update.

2. Make the lights a part of the spaceship in the form of attached fixtures. Remember: a single body can have multiple fixtures. Since collision detection is done using fixtures, you can use the OnCollision delegate on the light fixture, and simply always return false. This will cause all collisions to be ignored. However, because it is a real fixture, the centroid of the body will shift and the spaceship might now rotate or move like you want.