Character lands in irregular heights after jumping

I made a simple jumping mechanic using a raycast to check for “grounded” status.
However, when the character lands after jumping, sometimes it will stop a little higher, sometimes a little lower than expected.

Maybe I could use the Y coordinates of the platform to make it stop precisely where it’s meant to, but I have no idea how to do that. I’m really inexperienced.

Here’s my code:

void FixedUpdate ()
{
Raycasting ();

	if (spaceisdown == true)
	{	
		y_veloc = y_velocmax;
		spaceisdown = false;

			
	}

    
	if (grounded == false)
	{
		y_veloc = y_veloc - gravity;
	}
	transform.Translate (Vector2.up * y_veloc * Time.deltaTime);
}
void Raycasting()
{
	Debug.DrawLine (this.transform.position, groundedEnd.position, Color.green);
	grounded = Physics2D.Linecast (this.transform.position, groundedEnd.position, 1 << LayerMask.NameToLayer ("ground"));

}

I’d say moving the LineCast into void Update(){ } would be the issue, as Fixed Update is only called every 3 frames. So it’s probably just missing a frame or two between updating.

So just remove Raycasting() from FixedUpdate and add it to "void Update(){ Raycasting(); }

If this works, please mark as correct so others may know.