#Jump pad working only 50% of the time

1 messages · Page 1 of 1 (latest)

cold totem
#

exactly 50%?

tranquil jackal
#

Pretty much half the time it goes to the height I want it to and other hald goes to about half height

tranquil jackal
cold totem
#

interesting

#

show some more code

#

[]cb

distant riverBOT
#

Use codeblocks to send code in a message!

To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.

For example:
```cs
Console.WriteLine("Hello World");
```

Produces:

Console.WriteLine("Hello World");

To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.

tranquil jackal
#

thats all the code thats on the jump pad

#
    public float jumpForce;
    public float upForce;
    public int dirNum;
    public bool DIAGONAL;
    Vector2 dir;
    GameObject Player;

    void Start()
    {
        Player = GameObject.FindWithTag("Player");
    }

    void Update()
    {
        if (dirNum == 1)
            dir = Vector2.up;
        else if (dirNum == 2)
            dir = Vector2.down;
        else if (dirNum == 3)
            dir = Vector2.left;
        else if (dirNum == 4)
            dir = Vector2.right;
    }

    //LEFT AND RIGHT DONT WORK

    private void OnTriggerEnter2D(Collider2D other)
    {
        if(other.CompareTag("Player"))
        {
            StartCoroutine(DisableJump(.15f));
            other.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
            other.gameObject.GetComponent<Rigidbody2D>().velocity += dir * jumpForce;
            Debug.Log(Player.GetComponent<Rigidbody2D>().velocity);
            other.gameObject.GetComponent<PlayerMovement>().hasDashed = false;
            if(DIAGONAL)
            {
                other.gameObject.GetComponent<Rigidbody2D>().velocity += Vector2.up * upForce;
            }
            if(dirNum == 3 || dirNum == 4)
            {
                StartCoroutine(DisableMovement(.15f));
            }
        }
    }
    IEnumerator DisableMovement(float time)
    {
        Player.GetComponent<PlayerMovement>().canMove = false;
        yield return new WaitForSeconds(time);
        Player.GetComponent<PlayerMovement>().canMove = true;
    }

    IEnumerator DisableJump(float time)
    {
        Player.GetComponent<BetterJump>().enabled = false;
        yield return new WaitForSeconds(time);
        Player.GetComponent<BetterJump>().enabled = true;
    }
}
#

everything else isnt being called on this jump pad but all of them have the same issue

cold totem
#

what is disable jump

#

On the original script you showed me, comment out everything you think isn't being ran and see if the problem is still there

tranquil jackal
#

ok will try

#

nope still the same issue

#

Tried commenting out disable jump and that fixes it but now player can hold space to jump higher on bounce pad due to script being on

#
    public float fallMultiplier = 2.5f;
    public float lowJumpMultiplier = 2f;

    Rigidbody2D rb;

    PlayerInputAction controls;

    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        controls = new PlayerInputAction();
    }

    void Update()
    {
        if (rb.velocity.y < 0)
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
        }
        else if (rb.velocity.y > 0 && controls.Player.Jump.ReadValue<float>() == 0)
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }

    private void OnEnable()
    {
        controls.Enable();
    }

    private void OnDisable()
    {
        controls.Disable();
    }