Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im very new to C# and i do not understand the issue here, please help.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControlelr : MonoBehaviour {

public float moveSpeed;


void Start () {

}

// Update is called once per frame
void Update () {
if(Input.GetAxisRaw("Horizontal") > 0.5f)
(
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);<- right here is where the error comes up




if(Input.GetAxisRaw("Vertical") > 0.5)


{
}{
}}}

What I have tried:

ive tried putting more )'s there and ('s there and it keeps coming up
Posted
Updated 22-Sep-17 8:52am

Count the brackets:
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);
....................1...........2................3............3.....................................2
You are missing the bracket to close (1). I suspect it should be:
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
But it depends which methods you are using.

Hint: If you put the input cursor after a close bracket in VS, it highlights it's matching open bracket.

Oh, and the open bracket above that line should be an open curly bracket as well.

[edit]Finally! Got the stupid numbers lined up...[/edit]
 
Share this answer
 
v6
Advice: use a professional programmer's editor, they are loaded with features useful to programmers:
- proper indentation, it helps seeing program structure, that helps spotting some errors.
- parenthesis matching, when cursor is on a parenthesis, the matching one gets highlighted. This feature would have helped to spot the error in your code.
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControlelr : MonoBehaviour {

    public float moveSpeed;
    void Start () {
    }
    // Update is called once per frame
    void Update () {
        if(Input.GetAxisRaw("Horizontal") > 0.5f)
        (
        Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);<- right here is where the error comes up

        if(Input.GetAxisRaw("Vertical") > 0.5)
        {
        }
        {
        }
    }
}

Notepad++ Home[^]
UltraEdit | The Original Text Editor[^]

C#
( // <-the opening parenthesis on this line is unmatched, and I would have expected a curled one.
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);
 
Share this answer
 
v4
Comments
Member 13424404 26-Sep-17 23:25pm    
ok so i fixed the issue where you guys said and now im having it had the bottom with the curled parenthesis

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