- Home /
Whats wrong with my C-Sharp Script?
Here's my code:
using UnityEngine; using System.Collections;
public class ExampleCS : MonoBehaviour { public GameObject player2; public Vector3 pos = Vector3(1, 0, 1);
void Update () { player2.transform.position += pos; } }
And Here's my error:
Assets/Scripts/ExampleCS.cs(6,30): error CS0119: Expression denotes a `type', where a variable, value or method group was expected
please help me!
Answer by Jessy · Nov 29, 2010 at 06:25 AM
new Vector3(1, 0, 1)
Not just Vector3(1, 0, 1).
i tried that and i still get the error and also a warning saying that the "new" isn't needed
Then you're not actually making a C# script. I though maybe you created a .js file and tried to put C# code in it, but although that will give you a ton of errors, I didn't see the one you just mentioned. I have absolutely no idea what you did, but if you do what I said, the script compiles without any error.
Also, please wrap your codes in codes tags in the future.
Can you post the complete error warning - "the "new" isn't needed" . The code seems to work fine, unless you haven't posted the entire code.
Your answer
Follow this Question
Related Questions
Can you help me solve my C# script error? 1 Answer
Error on simple code cs0119 0 Answers
error with script plz help! 2 Answers
Enemy AI scripting error 2 Answers