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

Rigidbody is bugging

Discussion in 'Scripting' started by timoshaddix, Feb 15, 2016.

  1. timoshaddix

    timoshaddix

    Joined:
    Jan 7, 2014
    Posts:
    64
    Hello,
    Since i reopened my project today everything is acting weird, i might have changed something before i tested it.
    So it could be my code too, but it's doing this:


    basically, once i press spacebar it gives the player a small push which drives him forwards, building momentum.
    that did work well untill now, from 0:10 seconds on i stop pressing the spacebar, and it just keeps on going with the same speed, it doesn't increase or decrease, and all of a sudden, it jumps to a totally other speed!

    What could be the cause of this?

    this is what makes it move:

    Code (CSharp):
    1.     void FixedUpdate () {
    2.        OpDeGrondBlijven();
    3.        // float moveHorizontal = Input.GetAxis("Horizontal");
    4.         float moveVertical = Input.GetAxis("Vertical");
    5.  
    6.         Vector2 movement = new Vector2(1f, 0.0f);
    7.         if (Input.GetKeyDown(KeyCode.Space) && Energy.value >= 1)
    8.         {
    9.             Energy.value = Energy.value - EnergyWaarde;
    10.             //if (SliderScript.SliderValue > 46.5 && SliderScript.SliderValue < 54.6)
    11.             // {
    12.             rb.AddForce ( movement * SliderScript.SliderValue * StrengthAmount);
    13.             //rb.AddTorque ( 1 * SliderScript.SliderValue * StrengthAmount);
    14.             //rb.velocity = new Vector3(10, 0, 0);
    15.             //}
    16.  
    17.         }
    18.  
    19.  
    20.     }
    Greetings,
    Timo
     
  2. timoshaddix

    timoshaddix

    Joined:
    Jan 7, 2014
    Posts:
    64
    BUMP, i still haven't managed to solve it.