playMaker

Author Topic: new to playmaker, how would i go about doing something like this?  (Read 41229 times)

BigWFan

  • Playmaker Newbie
  • *
  • Posts: 1
I'm working on a 2d action platformer, right now I'm ironing out the character controller and its mostly to a place I like. however, one thing I've noticed is that if I jump and hold a direction against a wall I stick to it. this honestly feels pretty good, a sort of wall hang mechanic could be fun, so I just want to rig it up to play an animation. any tips on how to set that up? I was thinking checking speed, but it does seem that the speed/velocity is inconsistent despite the player not moving. then I figured a ray cast, is there a way to have a ray cast only turned on when you're jumping? I do have a ground check, might be able to do something like that, sorry if this is rambly, while typing i was figuring things out and trying new things.

Mosty1952

  • Playmaker Newbie
  • *
  • Posts: 1
    • solitaire bliss
Re: new to playmaker, how would i go about doing something like this?
« Reply #1 on: July 01, 2025, 03:28:26 AM »
Try it
Code: [Select]
bool isGrounded; // You already have ground check
bool isTouchingWall;
bool isWallHanging;

public Transform wallCheck;
public float wallCheckDistance = 0.2f;
public LayerMask wallLayer;

void Update()
{
    // Wall detection using raycast
    Vector2 direction = new Vector2(transform.localScale.x, 0); // face left or right
    RaycastHit2D wallHit = Physics2D.Raycast(wallCheck.position, direction, wallCheckDistance, wallLayer);
    isTouchingWall = wallHit.collider != null;

    // Wall-hang condition: in air + pressing toward wall + touching wall
    if (!isGrounded && isTouchingWall && Input.GetAxisRaw("Horizontal") != 0)
    {
        isWallHanging = true;
    }
    else
    {
        isWallHanging = false;
    }

    // Pass state to Animator
    animator.SetBool("isWallHanging", isWallHanging);
}

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Re: new to playmaker, how would i go about doing something like this?
« Reply #2 on: July 03, 2025, 10:58:11 AM »
I'm working on a 2d action platformer, right now I'm ironing out the character controller and its mostly to a place I like. however, one thing I've noticed is that if I jump and hold a direction against a wall I stick to it. this honestly feels pretty good, a sort of wall hang mechanic could be fun, so I just want to rig it up to play an animation. any tips on how to set that up? I was thinking checking speed, but it does seem that the speed/velocity is inconsistent despite the player not moving. then I figured a ray cast, is there a way to have a ray cast only turned on when you're jumping? I do have a ground check, might be able to do something like that, sorry if this is rambly, while typing i was figuring things out and trying new things.

You can control raycasting in many ways, including when the character jumps. Raycast comes with an action and often comes with a few parameters like direction and distance. Then there are further options like what to detect (filters), how many times a second, etc.
You can decide to direct the flow out of the state at any time and the raycasting will stop.

If your character registers micro-movements despite looking like it's glued to the wall, know that there are Transform constraints in Unity. You can lock X, Y or Z for example and test to see how this interacts with the physics. I would say that when the character is glued to a wall, locking on X would be a good thing to do. Then as soon as you jump, remove or deactivate the constraint.
It can be managed with a component.