Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Slide across walls

Discussion in 'Editor & General Support' started by GizmoBradwell, Apr 13, 2012.

  1. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
    There's lots of posts on this and i've tried physics materials, but I can't get a real resolution to this basic requirement.

    What do I need to do to get my first person to slide across walls, not be slowed down by them?

    I'm using the standard first person controller, if this is the problem and there's a setup that works, would someone kindly help me to not reinvent the wheel.

    Thanks for the help! :)
     
  2. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Slide scross walls and not be slowed down? I don't understand what this means; would you give us an example?
     
  3. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
    When you walk into a wall at an angle with the first person controller, the wall slows you down rather than freely sliding across it. You get the feeling of getting stuck when you go near a wall. Make sense?
     
  4. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Hmmm... I think I see what you're saying, but that would be pretty unrealistic. What do you expect to happen if the player is running almost perpendicular to the wall, such that there's only 1 degree of bias towards the right? Do you expect him to slide to the right as if he were running parallel to the wall?
     
  5. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Or do you mean that he's stuck at one point and won't budge at all, and you want him to slide very slowly to the right?
     
  6. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    Seen from a non-game perspective, part of the force moving the player forward when you walk into a wall at an angle goes into "friction" so to speak. In Unity I think that the forward velocity somehow gets translated based on the angle of the wall when the two colliders collide. This is purely a guess though, but I guess this happens internally somehow in the physics simulator. So basically you have to get around that. Normally with no physics I suppose when the collider hits a wall it would come to a dead stop, no matter if the wall is at an angle. So basically what you could do is to rotate the players move direction dynamically based on collision angle. That might cause a whole heaps of other problems though.
     
  7. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Assuming I'm correct in my assumptions I previously posted, then I would guess that the solution would involve detecting the collision, getting the collider's transform, and deducing the angle of the player in relation to the wall's collider, and applying the right amount of movement correction according to the slope.
     
  8. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
  9. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    That's good to know!