Question by
antonelundh · Aug 24, 2020 at 10:59 AM ·
rigidbody2dwalljump
Help with walljump/ wallstick script!,Help with walljump/ wallstick script!
I'm trying to make a walljump script based on Blackthornprod's walljump script but I want to stick to the wall. I found that I could constrain the rigidbody and it works but I can't jump. Anyone know how to fick this?
private void Update()
{
//Walljump
isTouchingFront = Physics2D.OverlapCircle(frontCheck.position, checkRadius, m_WhatIsWallJump);
if (isTouchingFront == true && m_Grounded == false && speed != 0)
{
wallStick = true;
animator.SetBool("wallstuck", true);
}
else
{
wallStick = false;
animator.SetBool("wallstuck", false);
}
if (wallStick)
{
m_Rigidbody2D.constraints = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
}
if (Input.GetButtonDown("Jump") && wallStick == true)
{
m_Rigidbody2D.constraints = ~RigidbodyConstraints2D.FreezePositionY | ~RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
wallJumping = true;
Invoke("SetWallJumpingToFalse", wallJumpTime);
}
if (wallJumping == true)
{
m_Rigidbody2D.velocity = new Vector2(xWallForce * -gameObject.GetComponent<PlayerMovement>().horizontalMove, yWallForce);
}
}
Cheers!
Comment