Cannot add magnet behavior programmatically

Jan 29, 2011 at 3:58 AM

Hello. I'm trying to add magnet behavior like this:

PhysicsControllerMain PC = LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;  

var behaviorCollection = Interaction.GetBehaviors(ball);            

var POB = new PhysicsObjectBehavior();          

POB.Mass = 1;

var PMB = new PhysicsMagnetBehavior();            

PMB.Magnetism = 1;



PC.AddPhysicsBody(ball.GetValue(PhysicsObjectMain.PhysicsObjectProperty) as PhysicsObjectMain);
Physics Object Behavior works right, but magnet doesn't. What am I doing wrong?


Feb 15, 2011 at 12:49 PM
Edited Feb 15, 2011 at 12:49 PM


I think that the magnetic behaviour is broken in the PH4 beta (it works in earlier versions though).

For my part, I reconstructed my game instead... :-)