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. Dismiss Notice

RigidBody Problems...

Discussion in 'Scripting' started by SomethingElse3163, Jan 28, 2015.

  1. SomethingElse3163

    SomethingElse3163

    Joined:
    Jan 28, 2015
    Posts:
    1
    When I Write This Code İt Always Giving Ne Errors,What Am I Doing Wrong ?;

    public class jumpSpeed = 250;

    Void Start()


    Void Update()
    If.(Input.GetButtonDown("Jump")
    rigidbody.AddForce(0,jumpSpeed,0);
     
  2. Ramsdal

    Ramsdal

    Joined:
    Oct 18, 2013
    Posts:
    251
    Im guessing that was pseudocode? Try this:
    Code (CSharp):
    1. public class Test : MonoBehaviour
    2. {
    3.     public float jumpSpeed = 250f;
    4.  
    5.     void Start()
    6.     {
    7.         //Nothing here
    8.     }
    9.  
    10.     void Update()
    11.     {
    12.         if(Input.GetButtonDown("Jump"))
    13.         {
    14.             rigidbody.AddForce(0,jumpSpeed,0);
    15.         }
    16.     }
    17. }
     
    Last edited: Jan 28, 2015
  3. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  4. Ramsdal

    Ramsdal

    Joined:
    Oct 18, 2013
    Posts:
    251