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

C# Keep Character Controller Within Gameobject edge Boundaries

Discussion in 'Scripting' started by kenaochreous, Dec 2, 2014.

  1. kenaochreous

    kenaochreous

    Joined:
    Sep 7, 2012
    Posts:
    395
    I have a character controller that is standing on top of a gameobject cube. I would to like to keep the character controller from going over the cube's edge boundaries. Is there a value I could check to see if the controller is near or going over the cube's edge boundaries? I want this to function like an invisible collider turned inside out, keeping everything inside rather than push it away.
    screen.png
     
  2. MysterySoftware

    MysterySoftware

    Joined:
    Sep 18, 2014
    Posts:
    46
    The easiest - and probably best solution - would be to just put four cube colliders around your ground.