I’m a teenage developer and I have never really coded in my life so I’m relying on video tutorials on how to use unity. What I want to be able to do is when I click a button the object move to the left or right of the screen. My solution to this is to create an if statement so that if the integer '‘xvalue’ is more than 0 then the object moves to the left else it moves to the right. This is my script so far, feel free to tell me if I’m doing anything wrong:
using UnityEngine;
using System.Collections;
public class lineswich : MonoBehaviour
{
int linepos =
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.Space))
GetNewLocation();
}
void GetNewLocation ()
{
// if line pos is more than zere move 5 units to left
if( linepos > 0)
{
// ... do this.
}
// If it is neither of those then...
else
{
// ... do this.
}
}
}
The voids are underlined with a red zigzag and when I hover over it is says “parser error unexpected symbol”.
Thanks for the help you give me.