using UnityEngine;
using System.Collections;
public class playerMovement : MonoBehaviour {
public float paddleSpeed = 1f;
public Vector3 playerPos = new Vector3();
// Update is called once per frame
void Update () {
float ypos = gameObject.transform.position.x + Input.GetAxis("Horizontal") * paddleSpeed;
gameObject.transform.position.x = ypos;
}
}
the above code seems perfectly fine to me yet it shows some errors saying to use temporary variable for gameObject.transform.position.x = ypos;
i just cant understand? would really apreciate if you guys explained me. i am kind of new to unity and new to game coding. so bear with me lol
using System.Collections;
public class playerMovement : MonoBehaviour {
public float paddleSpeed = 1f;
public Vector3 playerPos = new Vector3();
// Update is called once per frame
void Update () {
float ypos = gameObject.transform.position.x + Input.GetAxis("Horizontal") * paddleSpeed;
gameObject.transform.position.x = ypos;
}
}
the above code seems perfectly fine to me yet it shows some errors saying to use temporary variable for gameObject.transform.position.x = ypos;
i just cant understand? would really apreciate if you guys explained me. i am kind of new to unity and new to game coding. so bear with me lol