I’m following the tutorial listed below and I can’t figure out why my player (cube) is not moving like the tutorial shows. So, here’s the sample code and I’m wondering if the underlying API library has changed and that’s why the cube isn’t moving???
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float PlayerSpeed;
// Update is called once per frame
void Update () {
//Amount to move
float amtToMove = Input.GetAxisRaw("Horizontal") * PlayerSpeed * Time.deltaTime;
//move player
transform.Translate(Vector3.right * amtToMove);
//wrap
if (transform.position.x <= -7.5F)
transform.position = new Vector3(7.4F, transform.position.y, transform.position.z);
else if (transform.position.x >= 7.5)
transform.position = new Vector3(-7.4F, transform.position.y, transform.position.z);
}
}
Tutorial referenced:
http://www.3dbuzz.com/training/view/unity-standard/simple-2d-shooter/07-player-script-continued