Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Sticky Platform

Discussion in '2D' started by LeeDenbigh, Oct 6, 2015.

  1. LeeDenbigh

    LeeDenbigh

    Joined:
    Jul 7, 2014
    Posts:
    48
    Hi, can someone help me out with a problem that I can't seem to fathom out. I have a game object (player) that has a rigidbody2D and a circle collider attached. I want the player object to stick to a platform that is over it's head when jumped into. How would I go about that simply, and when the Colliders aren't touching the player just falls back to the ground?
     
  2. LeeDenbigh

    LeeDenbigh

    Joined:
    Jul 7, 2014
    Posts:
    48
  3. Prototypetheta

    Prototypetheta

    Joined:
    May 7, 2015
    Posts:
    122
    Add a head check, then tell it to kill vertical motion whenever it collides with said platform. Then you just need to make it so you can dismount that platform (maybe only have it check while a certain key is held down).

    You could do it with a new collider or good old raycasting.
     
    theANMATOR2b likes this.