Page 1 of 1

Sphere moving after it goes inactive.

Posted: Sun May 27, 2012 12:32 am
by RyanGadz
I'm making a golf game and I have the user putt the ball after the sphere/ball goes inactive. Problem is that the ball sometimes keeps moving after it goes inactive and I'm not sure how or why. Once it does this the user can no long apply an impulse to get it to move again. Any advice on what I should do?

Code: Select all

                Space = new Space
                {
                    DeactivationManager =
                    {
                        VelocityLowerLimit = .4f,
                        LowVelocityTimeMinimum = .00001f
                    },
                };

Code: Select all

 if (ballSphere.ActivityInformation.IsActive)
                {
// ball will be forced to slow down within a certain time after putting
                    timer2 += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    ballSphere.AngularDamping = .16f * (timer2 - timer);
                    ballSphere.LinearDamping = .16f * (timer2 - timer);

                }

Re: Sphere moving after it goes inactive.

Posted: Sun May 27, 2012 12:46 am
by Norbo
An object which is truly inactive does not receive position updates, so it cannot change positions. An inactive object can have a nonzero velocity, however; it's just not used to move the entity. (Keeping the velocity around makes the sleep-wake transition more robust.) If it's actually moving around, something is interfering (other impulses, state setting, kinematic-dynamic state switching, etc.).

Increasing the linear/angular damping a bunch over time will also make impulses fairly ineffective.

Re: Sphere moving after it goes inactive.

Posted: Sun May 27, 2012 12:59 am
by RyanGadz
Norbo wrote:Increasing the linear/angular damping a bunch over time will also make impulses fairly ineffective.
lol oh yeah I guess I never really reset the damping.. both are now set to zero right after the impulse and it seems to be working

thanks!