I have a problem too in unity can you help me i’m a beginner so i’m not very smart at this area. i have error assets/testing.cs(17,9): error CS8025: Parsing error this is the code:
using UnityEngine; using System.Collections;
public class Testing : MonoBehaviour {
// Use this for initialization
void Start () { }
// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.Space)) {
gameObject.transform.up.y = +1 ;
}
}
Thanks in advance Paul
PS: I’m Dutch so sorry if i have some write errors
Here is the error Assets/testing.cs(14,52): error CS0201: Only assignment call increment decrement and new object expressions can be used as a statement this is my current script: using UnityEngine; using System.Collections; public class Testing : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKeyUp (KeyCode.Space)) { gameObject.transform.y + 1 ; } } } So if you can help me again i would aprecieed it thanks in advance
Ok I reviewed the answer because it was not getting anywhere. Also your code above is not getting anywhere. Your perform an action but it is not stored anywhere. That is three anywhere in three sentences...anyway...
Vector3 position = gameObject.transform.position;
position = new Vector3(position.x, position.y + 1, position.z);
gameObject.transform.position = position;
that is it thanks but now i get another error i want to set x -= 1 this is the x += 1 script and that’s good but the x -= 1 scipt is wrong i don’t know what.
x += 1 script:
using UnityEngine;
using System.Collections;
public class X1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyUp (KeyCode.LeftArrow))
{
Vector3 vec = gameObject.transform.position;
vec.x += 1;
gameObject.transform.position = vec;
}
}
}
and now the x -= 1 script:
using UnityEngine;
using System.Collections;
public class X1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyUp (KeyCode.RightArrow))
{
Vector3 vec = gameObject.transform.position;
vec.x -= 1;
gameObject.transform.position = vec;
}
}
}
Thanks for your comment it was very useful but I get a new error now I will post it in days because i'm in class now so i has to stop.
– paulonlHere is the error Assets/testing.cs(14,52): error CS0201: Only assignment call increment decrement and new object expressions can be used as a statement this is my current script: using UnityEngine; using System.Collections; public class Testing : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKeyUp (KeyCode.Space)) { gameObject.transform.y + 1 ; } } } So if you can help me again i would aprecieed it thanks in advance
– paulonlOk I reviewed the answer because it was not getting anywhere. Also your code above is not getting anywhere. Your perform an action but it is not stored anywhere. That is three anywhere in three sentences...anyway...
– fafase