I’m trying to create a way where the player current position would be tracked so that the enemy would close to the player or throw explosives at the player.
public class Player : MonoBehaviour {
private float playerSpeed = 3;
public GameObject projectilePrefab;
//The next line is what I struggle with. This is the culprit!!!!!!
private float currentPosition = ;
//Or maybe if I do him like this:
void currentPosition() {
}
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
Move();
}
void Move()
{
//amount to move
float amntToMove = Input.GetAxisRaw("Horizontal") * playerSpeed * Time.deltaTime;
float amntToMove1 = Input.GetAxisRaw("Vertical") * playerSpeed * Time.deltaTime;
//Move character
transform.Translate(Vector3.right * amntToMove);
transform.Translate(Vector3.up * amntToMove1);
}
}