Question about Gravity

Jan 9, 2013 at 5:55 AM

Hi,

I'm a student using physics helper for the first time. I've done a few things but now I'm having problems with gravity. I want to turn off gravity to create a block-out application.

I've tried setting the HorizontalGravity and VerticalGravity of the physics canvas to zero, but a ball I  create within the canvas still behaves as if gravity is acting upon it.

How can I turn off gravity within a physics canvas so that all objects within that canvas no longer act as if gravity as acting upon them?

Thanks for your help.

Jan 12, 2013 at 4:50 AM

Hello? Helloo?

Coordinator
Jan 12, 2013 at 11:06 PM

Hello :)

Please see this post, which shows setting gravity at runtime - http://physicshelper.codeplex.com/discussions/277222

 

Jan 15, 2013 at 1:59 PM

I have tried to set GravityHorizontal and GravityVertical both zero.

But doesn't make any changes...

Coordinator
Jan 15, 2013 at 2:15 PM

Please be sure to set the properties on the Simulator, not the behavior. Note the red text below, it is using the Simulator object on the physics controller.

PhysicsControllerMain _physicsController = cnvGame.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;

{...}

Vector2 newVector = new Vector2();

newVector.X = 0;
newVector.Y = 10;

_physicsController.Simulator.Gravity = newVector;

 

 

Jan 15, 2013 at 2:22 PM

I try it now

Jan 15, 2013 at 3:23 PM

Wait...

Is this C# plus xaml?

Which reference has PhysicsControllerMain?

Coordinator
Jan 15, 2013 at 4:11 PM

This forum is for the "original" Physics Helper for Silverlight and Blend, which uses Behaviors.

Perhaps you are using the "newer" Physiscs Helper XAML project from here - http://physicshelperxaml.codeplex.com/ ??

If so, then you want to use the Simulator on the PhysicsCanvas object.