Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Conect11 · Jan 24, 2014 at 12:11 PM · colliderterraintrigger

Player sometimes, only occasionally falls through terrain

Edit Hi again: so, not sure this is going to be a solution to my issue of occasionally falling through the terrain (read below) but am wondering if adding a capsule collider to my player might help. I recently had the same issue with an NPC falling through the terrain when a rigidbody with gravity was applied, and placing a capsule collider on them stopped that. I'm gonna go ahead and try doing that, but thought I'd leave this edit here in case anyone has the same issue in the future and is looking for possible solutions. Carry on.

Original Post Woah, woah, woah, woah, woah there buddy, put down the rage hate. I know the topic of "player falls through terrain" appears over and over via Google. Totally cool with the answers. =) Not here to figure out how to stop it, because at this point in the game if I haven't done that by now I've got problems. For me, the issue isn't a constant. But, oddly, every now and then in gametesting the player will just take a step, and falls. It's not in the same place, just seems random, like they caught a crease in the mesh or something. Probably has happened 10 times in 700 gametests. (approx) Not enough to pull my hair out over, but enough to want to address. So I figure it's simply a glitch, one that I could live with as the occasional bug, but want to know how / if other folks address that in their games. Reason being, the project I'm working on uses an auto save feature, and player position is one of the things saved to playerprefs. That works great as long as things are going fine, but autosave in the middle of a freefall and the player's game is forever ruined. The first thought is to put a death collider just under the terrain, something to the effect of "ontriggerenter fadeout camera, transfer to a predetermined spot on the map, then die." That part would be pretty easy to code. Now, if there's a way to code "transfer to last known position on the terrain" that would be better, but I'm not picky. Just thought I'd ask how other folks handle an issue like this. Thanks, and God bless.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by _1 · Jan 28, 2014 at 09:39 PM

If I understand your question you want a "got to to last known position script" any easier way than doing that is to check the y coordinate under your ground and if the player is there he should go to the coordinate of the player such as this:

 function Update(){
 
 //example
 //if we are at this point at the y axis we will go up a little bit
 if(transform.position.y <= 0){
     transform.position.y = 1;
  }
 }

this code is very simple and choppy and there are lot better ways but make sure to adjust the value depending on the terrain or the platform's y axis hope this helps if this doesn't truly sorry. Good luck :)

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
Wiki

Answer by Nanocentury · Jan 29, 2014 at 12:49 AM

It's more a patch than a solution and may need some refinement but:

 Vector3 lastGoodPos;

 void Update()
 {
   RaycastHit hit = new RaycastHit();
   Ray ray = new ray(transfrom.position,Vector3.Down);
   if(Physics.Raycast(Raycast(ray, out hit)))
   {
     lastGoodPos = transfor.position;
   }
   else
   {
     transform.position = lastGoodPos;
   }
 }

It will use a raycast to determine if there is anything below the player and restore them to an arbitrary position if there isn't.

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 Conect11 · Jul 31, 2014 at 02:40 PM 0
Share

hey, thanks to both of you. Sorry I didn't say that before!

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Colliding with Terrain and Destroying it 1 Answer

GameObject going into terrain. 0 Answers

How Can I Load Massive Terrains In Sections? 0 Answers

Late Rocket Explosion 1 Answer

Can't click gameobject when over another trigger? 1 Answer


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