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 /
avatar image
0
Question by 4ntihero · Aug 24, 2015 at 11:51 AM · glitchfallingfloorfalling-through-floor

Falling through floor glitch

I'm making a simple 2.5 D platformer, and I'm running into a problem where the Player object is falling through the floor. It only happens sometimes; it only happens above a certain height, and not predictably even then. The player object has a rigidbody and a box collider, and some floors are planes, and some are cubes, each with their own simple colliders. I've fallen through both the cubes and the planes, and it seems to happen at random, and extreme heights don't seem to be a guarantee of recreating the glitch. I'm controlling the Player Character with a simple C# script (I plan to add more features after I get this part functioning reliably):

using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour {

 public float moveSpeed, jumpForce;

 Rigidbody rb;
 float horizontal;

 void Start () {
     rb = GetComponent<Rigidbody> ();
 }
 
 void Update () {
     if (Input.GetKeyDown (KeyCode.UpArrow) || Input.GetKeyDown ("w")) {
         Jump ();
     }
     horizontal = Input.GetAxisRaw("Horizontal");
     Vector3 movement = new Vector3 (horizontal * moveSpeed, rb.velocity.y, 0f);
     rb.velocity = movement;
 }

 void Jump(){
     rb.velocity = new Vector3 (rb.velocity.x, 0f, 0f);
     rb.AddForce (Vector3.up * jumpForce);
 }

}

Can anyone explain why this is happening so I can fix it?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Foulcloud · Aug 24, 2015 at 09:48 PM

Try pausing Unity mid jump and then advance frame by frame. If you find that the player can completely miss a collider from one frame to the next then this is the problem. Higher speeds and a very thin collider on the plane could be problematic.

If this is the case then you could make bigger colliders or use raycasts. With raycasting you could check the new "ground hit" position first and if it is greater than the raycast hit from the last position then use the hit position of the previous raycast as the new player position.

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 prof · Aug 25, 2015 at 12:59 AM 0
Share

(Raycast)... or compare yVelocity*deltaTime and raycast length, if velocity greater than length, set velocity to raycast length (or just set position directly)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Crouching and falling through floor 0 Answers

Fall Damage OnCollisionEnter Script Help. 1 Answer

Falling through the floor issue 11 Answers

On Unity, after I add the CharacterController and JavaScript, I keep falling through the cube floor i made, no matter how thick it is! Can someone help me? 2 Answers

zombies and the player SUDDENLY(not a beginning but a middle of playing) falling down 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