Good day.
I see so many errors…
First, for comment a line you must use //
Second, this is a function, not a variable change. If something have the () symbols, means its a function.
transform.Translate();
This is the function Translate() wich means MOVE!
You pretend to set initial position? then do:
transform.position = Vector3.zero;
Third, you want tio know when the player has reached endpos. So you must check for their position! You are now comparing its transform component, which has no sense…
you prentend to do this:
if (p1.position == endPos.position)
But, position is a float, so it have many decimals, and pretend that they will be exactly the same …is hard. So you should calculate the distance between that 2 positiond with Vector3.Distance() function and check if is smaller than some value…
if ((Vector3.Distance(p1.position, endPos.position) < 10)
And the Input.GetAxis you are using, you must define before that axis… Is better to just detect keys one by 1 to commence learning…
–
Look for Unity ansers about all of this, read read read, try try try.
It’s nice you try to do things at the beggining of learning, but maybe you should see more tutoprials, basic tutorials about Unity, learn what is a variable, a component, a class, a method, a function, etc…
Good luck!