Mathf.pingpong changes Y as well as X
I'm new to Unity and following the tutorial to extend the Roll-a-Ball project by adding an extended plane with obstacles. https://www.mvcode.com/lessons/roll-a-ball-obstacle-course The enemy cubes are supposed to move from side to side (on the X axis only) using Mathf.PingPong However, it seems the Y position also changes, but I don't want so!
The script EnemyMover contains the following
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class EnemyMover : MonoBehaviour {
 
     public float speed = 3;
     public float startingX;
     public float targetX;
     
     // Update is called once per frame
     void Update () {
         transform.position = new Vector3(Mathf.PingPong(Time.time * speed, 4), transform.position.y, transform.position.z);
 
     }
 }
 
               Written above this was the explanation "Mathf.PingPong(Time.time, 4) returns a value between 0 and 4 that changes over time, starting from 0, moving up to 4, then back down to 0, and continues like that forever "Ping Ponging" the value between 0 and 4. "
When I created the extended plane and reset it, it covered the initial plane so I figured that wasn't the right option!!
Your answer