-3

error CS1026: ) expected is my error message this is my code

using UnityEngine;

public class PlayerMovement : MonoBehaviour {

    // This is a reference to the Rigidbody component called "rb"
    public Rigidbody rb;

    public float forwardforce = 2000f ;


    // We marked this as fixedUpdate because we
    // are using it to mess with physics.
    void FixedUpdate ()
    {
        rb.AddForce(0, 0, forwardforce * Time.deltaTime);   // Add a force of 2000 on the z-axis

        if (Input.Getkey("d")

            (
                rb.Addforce(500*Time.deltatime, 0, 0);
            )
    }
}
1
  • you're missing a closing ) for the if statement's condition and you use parenthesis instead of curly braces for the if statement's block. please spend a few minutes proofreading your code befor asking for help
    – Piglet
    Commented Sep 16, 2022 at 8:08

2 Answers 2

0

As per comment above - your if statement should look like this:

if (Input.Getkey("d"))

{
      rb.Addforce(500*Time.deltatime, 0, 0);
}

Usually an IDE should point it out for you.

0

You made a mistake right here:

if (Input.Getkey("d")

        (
            rb.Addforce(500*Time.deltatime, 0, 0);
        )

You used (), instead of {}. There is a simple solution:

Use after the statement {}

.

if (Input.Getkey("d")

        {
            rb.Addforce(500*Time.deltatime, 0, 0);
        }

Not the answer you're looking for? Browse other questions tagged or ask your own question.