Below is my code. Its supposed to move my player in 8 directions(which it does) and also print to the Debug.Log what its current position is. but its giving me the error code;
Null
UnityEngine.Debug:Log(Object)
PlayerMovement:Update() (at Assets/Scripts/PlayerMovement.cs:27)
What am I doing wrong? Thanks for the help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public object playerPos;
public object player;
private void Start()
{
var player = GameObject.Find("Player");
var playerPos = player.transform.position;
}
void Update()
{
float x = Input.GetAxis("Horizontal") * Time.deltaTime * 7.0f;
float y = Input.GetAxis("Vertical") * Time.deltaTime * 7.0f;
transform.Translate(x, 0, 0);
transform.Translate(0, y, 0);
Debug.Log(playerPos);
}
}