Example #1
0
        public override void PlayerControl(Input input)
        {
            swordNode.movement.active = false;
            //sword.body.velocity = Utils.AngleToVector(sword.body.orient + (float)Math.PI/2) * 100;
            swordNode.body.velocity = swordNode.body.effvelocity * nodeKnockback;
            Vector2R rightstick = input.GetRightStick().toV2R();

            if (rightstick.LengthSquared() > 0.9 * 0.9)
            {
                movingStick = true;
                target      = rightstick;
                //enabled = true;
                target.Normalize();
                target            *= distance;
                target            += parent.body.pos;
                swordNode.body.pos = Vector2R.Lerp(swordNode.body.pos, target, 0.1f);
                //sword.body.pos = target + parent.body.pos;
                Vector2R result = swordNode.body.pos - parent.body.pos;
                swordNode.body.SetOrientV2(result);
            }
            else
            {
                movingStick = false;
                //enabled = false;
                Vector2R restPos = new Vector2R(parent.body.radius, 0).Rotate(parent.body.orient) + parent.body.pos;
                swordNode.body.pos    = Vector2R.Lerp(swordNode.body.pos, restPos, 0.1f);
                swordNode.body.orient = GMath.AngleLerp(swordNode.body.orient, parent.body.orient, 0.1f);
            }
            //sword.body.pos = position;
        }