Remove Forces from Particle

2 views
Skip to first unread message

will....@gmail.com

unread,
Jul 9, 2008, 5:13:12 PM7/9/08
to APE General
Hey,

So, I've been having some issues with removing forces from the
APEngine and from individual particles. Any kind of high level advice
on how to basically "zero" forces would be awesome.

1) For indiv. particles, how can you remove the forces for that
particle. I see that there is a forces array or something for
AbstractParticle, but I'm a little unsure of how you'd go about
removing a force you created for that particle. Specifically, what I
want to do is be able to control a player and independently control
the horizontal and vertical forces. So when the player moves forward,
add a horizontal force and when the player moves up, create a vertical
force. When the player stops moving horizontally, remove the
horizontal force but be able to keep the vertical force. Then, If the
player stops moving vertically, remove the vertical force. Etc.

2) For the APEngine, I'm trying to use the removeAllForce method like
so:

APEngine.init(1/4);
APEngine.container = this;
defaultGroup = new Group();
defaultGroup.collideInternal = true;
APEngine.addGroup(defaultGroup);

//etc.

//to add a gravity force

public function addGravity():void
{
APEngine.addForce(new VectorForce(false, 0, 2));
}

//to remove that force (which is the only one applied to the main
engine)

public function removeGravity():void
{
APEngine.removeAllForce();
}

...

so this doesn't really work. To test, I just have a circle particle.
When I call addGravity(), the ball begins to fall. But when I call
removeGravity(), the ball slows down ever so slightly, but doesn't
stop.

Actually, I'm realizing that's probably because the velocity of the
ball is being changed...

thanks for any help. I love playing around with this, and this is
really the main issue I've been stymied by.

w

Frédéric Gascon

unread,
Jul 9, 2008, 6:30:10 PM7/9/08
to APE General
It's not a programmation probleme, it's a physic probleme. When you
apply no force at all on a particle it keep is speed unchanged.
So when you start your program the speed of the ball is 0 and the
force applied to it is 0 too. When you add the gravity the force
applied to it is 2 and the speed start increasing. Then you stop the
gravity, so the force is at 0 and the speed stop increasing, but stay
at his current value. So the ball will keep moving but won't
accelerate anymore. That's how it would happen in the reality if you
recreate this situation, so it work well.
http://en.wikipedia.org/wiki/Newton%27s_laws_of_motion

But now if you want the particle to stop moving you should:reset it's
speed to 0 or add some frictional force that will slowly stop it or
add some other particles that will stop it.

On 9 juil, 17:13, "will.car...@gmail.com" <will.car...@gmail.com>
wrote:

will....@gmail.com

unread,
Jul 9, 2008, 8:25:44 PM7/9/08
to APE General
thanks a lot -- yeah, I understand what's going on.

is there any way to remove a force on a specific particle? I can see
it's in the TO DO for the Abstract Particle class... anyone tried
implementing this?

thanks,
w

On Jul 9, 3:30 pm, Frédéric Gascon <frederic.gas...@gmail.com> wrote:
> It's not a programmation probleme, it's a physic probleme. When you
> apply no force at all on a particle it keep is speed unchanged.
> So when you start your program the speed of the ball is 0 and the
> force applied to it is 0 too. When you add the gravity the force
> applied to it is 2 and the speed start increasing. Then you stop the
> gravity, so the force is at 0 and the speed stop increasing, but stay
> at his current value. So the ball will keep moving but won't
> accelerate anymore. That's how it would happen in the reality if you
> recreate this situation, so it work well.http://en.wikipedia.org/wiki/Newton%27s_laws_of_motion
Reply all
Reply to author
Forward
0 new messages