public override void Iterate()
        {
            deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
            deltaVelocity.Y = 0.0f;

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= this.Stiffness;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

                if (!BodyWalkingOn.IsStatic)
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }
            }
        }
            public override void Iterate()
            {
                _deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
                _deltaVelocity.Y = 0.0f;

                _deltaVelocity *= Stiffness;

                if (Math.Abs(_deltaVelocity.LengthSquared()) > 0.00001f)
                {
                    Body1.IsActive = true;
                    Body1.ApplyImpulse(_deltaVelocity * Body1.Mass);
                }

                if (_shouldIJump)
                {
                    Body1.IsActive = true;
                    Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

                    if (!BodyWalkingOn.IsStatic)
                    {
                        BodyWalkingOn.IsActive = true;
                        BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                    }
                }
            }
    public override void Iterate()
    {
        deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
        deltaVelocity.Y = 0.0f;

        deltaVelocity *= 0.02f;
        if (BodyWalkingOn == null)
        {
            deltaVelocity *= .1f;
        }

        if (deltaVelocity.LengthSquared() != 0.0f)
        {
            // activate it, in case it fall asleep :)
            Body1.IsActive = true;
            Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
        }

        if (shouldIJump)
        {
            Body1.IsActive = true;
            Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

            if (!BodyWalkingOn.IsStatic)
            {
                BodyWalkingOn.IsActive = true;
                // apply the negative impulse to the other body
                BodyWalkingOn.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass, contactPoint);
            }
        }
    }
Esempio n. 4
0
        public override void Iterate()
        {
            var deltaVelocity = targetVelocity - Body1.LinearVelocity;

            if (deltaVelocity.LengthSquared() > 0.000001f)
            {
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }
        }
        public override void Iterate()
        {
            deltaVelocity = TargetVelocity - Body1.LinearVelocity;
            if (deltaVelocity.Y > 0 || isJumping)
            {
                deltaVelocity.Y = 0;
            }

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= Stiff;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                isJumping      = true;
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);
                System.Diagnostics.Debug.WriteLine("JUMP! " + DateTime.Now.Second.ToString());

                if (!BodyWalkingOn.IsStatic && World.RigidBodies.Contains(BodyWalkingOn))
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }
            }

            //if (!isJumping && !isGrounded)
            //    deltaVelocity.Y = -1.0f;

            //Text = isJumping + " " + shouldIJump;
        }