6
\$\begingroup\$

I'm doing some research and I really don't want a physics engine when a simple mechanism will do. I have a ball that will be balanced on a plane. The ball will always be "stuck" to the plane and never roll off of it. The player/user will be moving this plane vertically up and down, changing its angle (rotating it some) and changing it's length. What I want is for the ball to roll along the plane as the user is interacting with the plane.

For example, player touches a surface with two fingers, touch 1 is the plane starting vector and touch 2 is the plane ending vector. The player can then move the two fingers around (increasing/decreasing the length of the plane) as well as move their fingers vertically and horizontally changing the planes position in 2d space. While doing this the ball moves along the plane with normal gravity trying to pull the ball down to the ground.

Does anyone have any idea on how to approach this? I started to think that this would be simple but then figuring in the dynamically changing length of the plane I got a bit lost.

I'll be doing this in XNA or Silverlight.

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

I don't know if I understand your problem correctly, but here is how I would go with the constraints that I understood:

I guess you could simply apply gravity to the ball, then resolve the collision with the plane by moving the ball above the plane perpendicularly to the surface, making the ball move along the plane based on the orientation of the surface.

If you want to prevent the ball from falling from the plane, then just restrict its position when it gets to the borders of the plane.

As for the dynamic changing length, the only problem that I would see is when the user would want to make the plane smaller than it actually is when the ball is at the border. You could just solve this by moving the ball along with the new border.

\$\endgroup\$
1
  • \$\begingroup\$ Sounds right, I guess it's simpler than I thought. \$\endgroup\$
    – Marc
    May 19, 2011 at 3:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .