So, I wrote a script to make a player moves in X position.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Vector2 targetPosition;
public float Xincrement;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
targetPosition = new Vector2(transform.position.x + Xincrement, transform.position.y);
transform.position = targetPosition;
}
}
}
but it simply didn’t work. So I sent it to a friend, asking him for help. He tested it on his computer, and it worked just fine. The difference is that his unity is in version 2018.3.9f1, while myunity is in version 2019.2.13f1.
Does it change anything? What should I do to make it work on my computer?