Making an object repeat its movement from a different point after reaching a coordinate

Hello, I’ve just started learning unity and c# and would like some help or be pointed to the direction where i can solve this problem.
I created an object that will move along a coordinate and collide with objects along its way, and I needed the object to return to a different coordinate along its path after hitting a collider boundary I made.

Point A (0,0,0)
Point B (0,1,0)
Point C (0,10,0)
Projectile spawn at (0,5,0) and travel towards (0,10,0)
for this I tried using mathf.repeat
transform.position = new Vector3(transform.position.x, Mathf.Repeat(7, 10), transform.position.y);

it moved the object 1 unit in the y direction instead. currently it moved to (0,6,0) the closer the object i moved towards 0,10,0 it moved to the Z axis position instead.

what I want it to happen is the projectile to move 7 units towards Point C (0,10,0) and then continue 2 units from 0,1,0 and end on 0,3,0

Icould achieve that by using 2dcolliders at the coordinate making many box objects around the 10x10 field to change the transform.position to 0,1,0 if it trigger the collider but there’s a problem when I tried sending the object diagonally from 0,5,0 to any diagonal position which should be looping diagonally opposite of where it collider(going to open a separate question for this).
it kind of works but I want to learn doing it using mathf solution if possible.
Please advise ._.

TLDR: Using those old RPG maps where the character walks north and then ends up popping out from the south and keeps walking north

Why do you want to use Mathf.Repeat method for this? I don’t exactely get what you want to achieve, but you might want to try something like this (untested code)

Vector3 speed = new Vector3(2f,1f,0f); //speed
Vector3 bounds = new Vector2(10f,10f); //boundaries to return
Vector3 currentPosition =; //tracks current position

public void Start()
	//set initial position
	currentPosition = object.transform.position;

public void Update()
	//calculate wanted position
	currentPosition = currentPosition + speed * Time.deltaTime; //add Time.deltaTime to keep movement frame consistent

	//use Mathf.Repeat to ensure we keep in between our bounds
	transform.position = new Vector3(Mathf.Repeat(currentPosition.x,bounds.x), Mathf.Repeat(currentPosition.y,bounds.y), 0f);

transform.position should keep in between 0,0 and 10,10 while our currentPosition vector holds the real calcuclated position.