Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
using UnityEngine;

public class playermovement : MonoBehaviour{
	// This is a referd to ridgidbody componetnt called "rb"
	public Rigidbody rb;

	public float forwardForce = 2000f;
	public float sidewaysForce = 500f;

    // We marked this "FixedUpdate" because we 
	// are using it mess with phycics
    void FixedUpdate()
	{
		// add a fource 
        rb.AddForce(0, 0, forwardForce * Time.deltaTime);
		
		if(	 Input.GetKey("d"){
				rb.AddForce( sidewaysForce* Time.deltaTime,  0,  0);
		}
		
		if(	 Input.GetKey("a"){
				rb.AddForce( -sidewaysForce * Time.deltaTime,  0,  0);
		}
    }
}


What I have tried:

bro plese tell me hoe to do this plese tell me i will give you 100000 dolar plese help me mem e
Posted
Updated 7-Jul-21 1:26am
v2
Comments
Richard MacCutchan 7-Jul-21 5:34am    
It is most unlikely that you have 100,000 dollars to give away so please do not pretend that you have.

Quote:
plese tell me plese tell me i am in danger my boos is JUST STRICK ST ME PLESE TELL ME THE solution

To be honest, if you can't fix basic syntax errors like that in trivial code then the chances are you "boos" is rightly annoyed: you have blagged your way into a job you have no idea how to do.
So I'm going to assume you are lying and this is homework. Maybe we can teach you something, even if you are a liar - do it again, and I'll get very annoyed with you.

This is a basic syntax error, so start by looking at the error message:
cs(21, 25): error CS1026: ) expected
This tells you many things:
1) The file name (but you have cut that off and just left "cs" which is the file extension).
2) The line the error was located on: 21
3) The column it was found on: 25
4) A error number: CS1026 - you can google this and get a "better explanation"
5) What it found wrong: It expected a ")" and didn't get one.

So look at that line of code:
C#
if(  Input.GetKey("a"){
You open two sets of brackets:
C#
if(  Input.GetKey("a"){
  ^              ^
But you only close one:
C#
if(  Input.GetKey("a"){
  (              (   )
So it complains.

How do you fix that?
You add the missing close bracket:
C#
if(  Input.GetKey("a")){
                      ^


Was that so complicated to work out?

In future try thinking about syntax errors instead of just going "BWAA! I don't understand!"

And never, ever lie to us again.
 
Share this answer
 
You are missing the second closing parenthesis:
C#
if(  Input.GetKey("a"){
                     ^ a second ) required here

And the same problem on line 25.
 
Share this answer
 
v2
Quote:
How do I stop the proble (cs(21, 25): error CS1026: ) expected)

C#
    if(  Input.GetKey("d"){
//    ^ here you open a '(', but you never close it
            rb.AddForce( sidewaysForce* Time.deltaTime,  0,  0);
    }

    if(  Input.GetKey("a"){
//    ^ here you open a '(', but you never close it
            rb.AddForce( -sidewaysForce * Time.deltaTime,  0,  0);
    }

C# If ... Else[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900