Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by R-GiGgS84 · Oct 04, 2011 at 03:07 AM · charactercontrollerfallingedge

How to prevent Character Controller from falling of the edge?

As mention above, is there a way to prevent the character controller from walking to it's death if there is no more ground to walk?

I have find a similar question as posted here:

http://answers.unity3d.com/questions/37407/character-controller-problem.html

But i have no idea on how to use it to my advantage. Can anyone be kind enough to advice me on that?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image timsk · Oct 04, 2011 at 10:21 AM 0
Share

other than pathfinding, just put a collider on the edge, this will act as an "invisible wall"

avatar image R-GiGgS84 · Oct 05, 2011 at 07:21 AM 0
Share

Thanks for the reply. Is it possible to do it programmatic way? By the way, what is the pathfinding thingy u mention about? Care to shed some light on me?

avatar image syclamoth · Oct 05, 2011 at 07:34 AM 0
Share

'pathfinding' is the arcane art of writing programs which can locate and avoid obstacles between themselves and their goals. It's pretty complicated.

As for doing it programmatically, it really depends on the exact structure of the mesh you are walking on. For some things it would be relatively straightforward, but for most it's pretty hard to arbitrarily decide whether a player should be able to walk off something (is it a balcony, or is it a drop into the void? The program doesn't know!)

avatar image GreenSignalGames · Jul 11, 2017 at 06:28 AM 0
Share

Is there really no way to just turn off gravity? I feel like that may be what some people are looking for. I know that's what I'm looking for.

Edit: I know you can turn it off in the project, but unfortunately when I do that, I can no longer control the character. They won't move if there is 0 gravity. It's very frustrating. Especially when Rigidbody has a "Use Gravity" check box, which doesn't seem to me to do anything at all on a character.

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by NickLD · Dec 30, 2014 at 11:01 AM

to do it in script, I would first make a raycast a short distance in front of you pointing downwards. if the ray returns a false(meaning it has hit no colider) then ignore player forward input key. That way they cant go over the edge.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Don-Tako · Dec 17, 2018 at 06:22 PM 0
Share

this works, but not provide a smooth movement because player stops suddenly on reach the edge

avatar image
0

Answer by supergamespawn · Oct 06, 2011 at 03:59 PM

the easy way is to make a cube into a wall and where you can change the cubes texture or color(sorry i forgot what its called)find a cloro thats invisible and the player will walk into the cube and not fall off

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Sindorej · May 11, 2014 at 12:11 PM

This is an old post, but for people searching for this the solution is to create an EmptyObject and attach a Collider to it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by OZAV · Apr 25, 2016 at 02:48 PM

. ..and, again, as i always say, this is kinda thread that will NEVER get old, as long a people make games in Unity. *Good that admins did NOT have it closed, thanks. So, here, (for now, and all future readers of this thread): you need to make in CODE, and define IN CODE a Square Matrix, after which bound player is considered out of it. Here's the (my simpler version) you can use, and additionally modify, for the task (you only MUST drag your center of your each map each time to be 0,0,0, in coordinates, for using this script in SUCCESSFUL manner) So, any objects you want to limit how far, or high it can go, just attach this script to it, and enter desired limits in Inspector: (*you may also add your damage call line, later, as well): here, my clean "LimitWorldBoundaries" script: LimitWorldBoundariesScr


limitworldboundaries.zip (926 B)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by hukondejo · Oct 17, 2017 at 05:53 AM

I've answered in a similar thread, but I think this script will be useful to this issue too.

The script prevents the falling. While your terrain will be generated in 0 height (yaxis) at start everything whats bellow zero height(yaxis) will be automaticaly respawnned to their starting point. You can use it not just on the player but everything else what uses gravity.

http://answers.unity3d.com/comments/1419816/view.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Player falls too fast after moving off from an object. 1 Answer

Implementing falling: How to maintain forward inertia as I transition into a fall animation? 0 Answers

Change rigibody velocity without affecting other axis 0 Answers

How to keep moving an object only with its speed? 0 Answers

Apply code to a gameObject with EventTrigger 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges