Moving my 2D object in a circular motion, but it would still be pointing to the center of the circle

Hello Everyone,

I have a 2D GameObject which is an arrow head , i have gotten it to move in a circular motion around a circle , but i have noticed that when it rotates the tip of the Arrow head does not point to the center of the circle. What i want is for the tip to always point to the center of the circle when it rotates . Any ideas would greatly appreciated.

there are a lot of ways of doing it. look up 2D LookAt()

1 Like

you may also be able to just fix your anchors or rotate the object equally opposite to achieve the same effect

1 Like

I have solved the problem, with â€śtransform.RotateAround()â€ť , the problem am having now is how to make my gameobject mirror my touch input. If I make a circular gesture to the left or right , I want my gameobject to do the same.

Everyone thank you for your replies,

I have solved the problem, with â€śtransform.RotateAround()â€ť , the problem am having now is how to make my gameobject mirror my touch input. If I make a circular gesture to the left or right , I want my gameobject to do the same.

I just did something similar in VR with

``````Vector3 eulerRotation = new Vector3(0, 0, transform.eulerAngles.z);
collidingObject.transform.localRotation = Quaternion.Euler(eulerRotation);
``````

this method works if you want to lock one obejcts rotation on a single axis to anothersâ€¦ not sure exactly what u want

This is my Code, to give you a feel of what am trying to achieve.

if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{

// Get movement of the finger since last frame
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;

//actual touch
Touch touchPoint = Input.GetTouch(0);
//current touch x position
float touchPointCurrPos = touchPoint.position.x;
//previous touch x position
float touchPointPrevPos = touchPoint.position.x - touchDeltaPosition.x;
//difference between previous and current finger position
float Diff = touchPointPrevPos - touchPointCurrPos;

//rotates to the left
if (touchPointCurrPos < touchPointPrevPos )
{
transform.Rotated(fixedGameObject.transform.position, new Vector3(0,0,1), +RotateSpeed *Time.deltaTime
}
//rotates to the right
if (touchPointCurrPos > touchPointPrevPos)
{
transform.Rotated(fixedGameObject.transform.position, new Vector3(0,0,1), -RotateSpeed *Time.deltaTime

}

}
}
}

can you use code tags for all of it plz

Please am sorry , am new to Unity .

``````          if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{

// Get movement of the finger since last frame
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;

//actual touch
Touch touchPoint = Input.GetTouch(0);
//current touch x position
float touchPointCurrPos = touchPoint.position.x;
//previous touch x position
float touchPointPrevPos = touchPoint.position.x - touchDeltaPosition.x;
//difference between previous and current finger position
float Diff = touchPointPrevPos - touchPointCurrPos;

//rotates to the left
if (touchPointCurrPos < touchPointPrevPos )
{
transform.Rotated(fixedGameObject.transform.position, new Vector3(0,0,1), +RotateSpeed *Time.deltaTime
}
//rotates to the right
if (touchPointCurrPos > touchPointPrevPos)
{
transform.Rotated(fixedGameObject.transform.position, new Vector3(0,0,1), -RotateSpeed *Time.deltaTime

}

}
``````