Doing a cert III and IV in screen media and games programming atm, I'm ahead of class but I'd like to know whats wrong in this code.
I know all the shit I gotta do, but for some reason its giving me errors.
Programs:
Visual Studio
Unity
[code]
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.W);
rigidbody.AddForce(3,0,0);
}
}
[/code]
[editline]12:25PM[/editline]
Not really sure how to start it off from the void update, I have about 4 scripts written for a crappy FPS, but its at the uni atm and I forgot how to start from
[code]
void Update () {
}
[/code]
why do you have a ; after an if case
[code]
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
// Use this for initialization
public void Start()
{
}
// Update is called once per frame
public void Update()
{
if (Input.GetKey(KeyCode.W))
rigidbody.AddForce(3, 0, 0);
}
}
[/code]
Fixed your style to look more like the standard C# one.
Also, yes, you shouldn't put the ; after an if.
Oh, I just noticed, you were also missing a closing ) in your if.
Not 100% sure but you also forgot the public access modifier.
Ahh, thanks guys for the help, I appreciate it.
Sorry, you need to Log In to post a reply to this thread.