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 Naerly · Jan 27, 2017 at 02:43 PM · collisionrigidbody

Rigidbody randomly fall through floor

Hi everyone I had a weird issue with my project. When I make my character jump, he randomly fall through the floor like this: http://plays.tv/video/588b59f23a5950461c/wtf-unity

I don't understand why it's happening.

Here is the script of the character controller that is affecting this rigibody:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerController : MonoBehaviour {
 
     float move;
     public float moveSpeed = 12f;
 
     public bool isJumping = false;
     public bool grounded =  false;
     public bool toped = false;
 
     float jumpForce = 175f;
     float jumpTime;
     float jumpMaxTime = 0.3f;
 
 
     public GameObject gameController; // On récupère le GameObject contenant le GameController
     GameController gameControllerScript; // Variable pour stocker le script GameController
 
 
     // Use this for initialization
     void Start () {
         gameControllerScript = gameController.GetComponent<GameController>(); //On récupère le script GameController
     }
     
     // Update is called once per frame
     void Update () {
 
         move = Input.GetAxis("Horizontal");
         GetComponent<Rigidbody>().velocity = new Vector3 ( move*moveSpeed , GetComponent<Rigidbody>().velocity.y - gameControllerScript.gravity, GetComponent<Rigidbody>().velocity.z);
         print (grounded);
 
 
 
         if (grounded) {
             
             if (Input.GetButtonDown ("Jump")) 
             {
                 jumpTime = 0f;
                 isJumping = true;
             }
         }
 
         if (isJumping) {
             
             jumpTime+= Time.deltaTime;
 
             if (((toped) || jumpTime >= jumpMaxTime || Input.GetButtonUp("Jump")) & (jumpTime > 0.3f)) {
                 isJumping = false;
             }
 
             GetComponent<Rigidbody>().AddForce(Vector3.up * jumpForce);
         }
 
     
     }
 
 }
 

And here is some screenshots from Unity:

alt text

alt text

What is happening and what can I do to fix this? If you have any things you can say about my code don't hesitate as well if you have any advice :)

ss2017-01-27at033833.png (257.4 kB)
ss2017-01-27at034024.png (232.8 kB)
Comment
Add comment · Show 1
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 hexagonius · Jan 28, 2017 at 01:30 PM 1
Share

Use FixedUpdate ins$$anonymous$$d of Update. You're messing with physics in the wrong loop.

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Rigidbody going through wall during pinch-to-zoom 0 Answers

Rigidbody going through Colliders help! 1 Answer

How to Make A Character Stop At Wall? 0 Answers

Detecting collisions on an invisible grid 0 Answers

Unity 5: AddForce Increases power when already being pushed towards a collider. How to make stop? 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