Move and Rotate player in circular motion?

i want to move and rotate player in circular motion i have a script but that move and rotate player alwayes from zero position? i want to move player in circular motion from its current position.

	public Vector3 TargetPos;
	public int speed;
	float TimeCounter = 0.0f;
	float x,y,z;
	public float radius;
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {

		TimeCounter += Time.deltaTime *speed;
	}


	public void Forward()
	{
		
		x = transform.position.x;
		y = Mathf.Cos (TimeCounter) * radius;
		z = Mathf.Sin (TimeCounter) * radius;
		transform.position =   new Vector3(x,y,z);
		transform.Rotate (speed,0,0);
	}

There’s a lot to unpack, and I must guess at some of your intent.

None of this appears to be working as you expect from what I can see, but the main question you’ve asked I shall answer first.

The reason this is at the origin (0,0) is because the version of the rotation formula you’re using is supposed to be at the origin (this concept must be performed in a local space, so that’s correct). The resulting y and z must be “vectored” to the transform’s current position, so if I assumed y and z were correctly calculated to begin with (and I’m fairly sure they’re not), this would suffice:

transform.position = new Vector3(x, transform.position.y + y, transform.position.z + z);

There’s more work to be done, but I’ll leave that after I know more about the following issues:

I have no idea, for example, what speed and TimeCounter are, but because you’re using TimeCounter as a parameter to Cos and Sin, you intend that to represent the angle of rotation. I have to be certain this is an angle of rotation expressed in radians, but I see nothing that would “wrap” the value so as to ensure it remains within a logical range of a radian value.

Further, in the form of rotation you’re using, there is no width and height to be used. In this form the rotation assumes a length (the radius) starts on the y axis (in this yz format), and is rotated clockwise where the angle is positive, so both of the trig functions should be multiplied by radius, not two different values (width and height).

Finally, among my caveats of assumption here, the transform.Rotate suggests you intend not only to move the object’s position around a central point, but to have the object’s orientation to rotate synchronously so as to maintain relative orientation to the center of rotation, but I assume that isn’t working because, in theory, speed should not be changing. I think what you should do here is to apply the same rotation you’re using for the trig above, but create a Quaternion from Euler angles, duplicating the current Y and Z axis, but setting the X axis of rotation to that of your computed angle (or some mirrored version of it as appropriate).

Hello all,
I am also working in similar problem. I want to rotate an object in a circular way but I do not clearly understand if there should be the use of Time.deltatime for making the movement in circular rotation. I have searched for so many videos but still I am confused.
This is my code:

float x, y, z;
float radius = 5;
public float timeCounter = 0;

    private void MoveBall()
    {
        x = Mathf.Cos(timeCounter * Mathf.PI/180) * radius;
        y = 0.5f;
        z = Mathf.Sin(timeCounter * Mathf.PI / 180) * radius;  
        timeCounter += 1;
        transform.position = new Vector3(x, y, z);
    }

Is this code correct to make an object move around in circular path? I have printed out and checked the answers for few angles (0 to 5 degrees ) and it shows right. Still I am not sure.
Is there a need to add Time.deltatime in this ? Does deltatime contribute to anything ?