Exemple #1
0
    void Start()
    {
        controller = GetComponent <Controller2d>();

        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
    }
    void Start()
    {
        controller = GetComponent <Controller2d>();
        ignorethis = moveSpeed;

        //gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        //jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
    }
Exemple #3
0
    void Start()
    {
        controller = GetComponent <Controller2d>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        print("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity);
    }
    private void Update()
    {
        base.Update();

        float velOut = 0f;

        Velocity.y = 0f;
        Velocity.x = Mathf.SmoothDamp(Velocity.x, _moveSpeed, ref velOut, 0.2f);
        Controller2d.Move(Velocity * Time.deltaTime);
    }
Exemple #5
0
    void Start()
    {
        controller = GetComponent <Controller2d>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); // D=1/2gt^2  =>  Distance= 1/2 *gravity*time^2
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        Debug.Log("velocityMin" + minJumpVelocity);
        Debug.Log("velocityMax" + maxJumpVelocity);
    }
Exemple #6
0
    private new void Update()
    {
        base.Update();

        FallCheck();

        // Do not accumulate gravity if colliding with anythig vertical
        if (Controller2d.Collisions.FromBelow || Controller2d.Collisions.FromAbove)
        {
            Velocity.y = 0;
        }
        if (_actionMovement.BounceBackActive)
        {
            ApplyBounceBack();
        }
        else
        {
            CalculateVelocityOffInput();
            ApplyGravity();
            Controller2d.Move(Velocity * Time.deltaTime, DirectionalInput, JoystickId);
            // Reset the jump indicator once we've made contact with the ground again
            if (_jumped && Controller2d.Collisions.FromBelow)
            {
                _jumped = false;
            }
        }

        CalculateMovementAnimation();
        CalcualteFacingDirection();
        CalculateWeaponRotation();
        DevelopmentHealthHack();
        CheckForUltReady();
        CheckForUltimateUse();

        // Check for weapon switching
        if (Input.GetButtonUp(JoystickId + GameConstants.Input_LBumper) || Input.GetKeyUp(InputManager.Instance.ChangeWeapon))
        {
            _weaponManager.SwitchWeapon();
        }
    }
Exemple #7
0
 protected override void Move()
 {
     Animator.SetFloat("Velocity", Mathf.Abs(Velocity.x));
     Controller2d.Move(Velocity * Time.deltaTime);
 }