Skip to main content
Post Closed as "Not suitable for this site" by user1430
format and tagging, added information from comments the author should really have included in the quesiton in the first place.
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

using UnityEngine; using System.Collections;

public class player_controler : MonoBehaviour {

using UnityEngine;
using System.Collections;

public class player_controler : MonoBehaviour {

    public float moveSpeed;
    public float jumpHeight;

    // Use this for initialization
    void Start () {
    }
    
    // Update is called once per frame
    void Update () {

        if(Input.GetKeyDown) (KeyCode.Space)) 
        {
            rigidbody2d.velocity = new vector2(0,jumpHeight;)
        } 

    }
}

} This is what shows up:

Assets/scripts/player_controler.cs(16,53): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

using UnityEngine; using System.Collections;

public class player_controler : MonoBehaviour {

public float moveSpeed;
public float jumpHeight;

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {

    if(Input.GetKeyDown) (KeyCode.Space)) 
    {
        rigidbody2d.velocity = new vector2(0,jumpHeight;)
    }

}

}

using UnityEngine;
using System.Collections;

public class player_controler : MonoBehaviour {

    public float moveSpeed;
    public float jumpHeight;

    // Use this for initialization
    void Start () {
    }
    
    // Update is called once per frame
    void Update () {

        if(Input.GetKeyDown) (KeyCode.Space)) 
        {
            rigidbody2d.velocity = new vector2(0,jumpHeight;)
        } 

    }
}

This is what shows up:

Assets/scripts/player_controler.cs(16,53): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Source Link

can someone help me with this code for my platformer. ive been working on the script for an eternity but unity keeps saying there is an error

using UnityEngine; using System.Collections;

public class player_controler : MonoBehaviour {

public float moveSpeed;
public float jumpHeight;

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {

    if(Input.GetKeyDown) (KeyCode.Space)) 
    {
        rigidbody2d.velocity = new vector2(0,jumpHeight;)
    }

}

}