I am trying to rotate my player along the centre of the world in Unity3D. All the tutorials and references I have looked through till now have left me to this working code:
void MoveAlongCurve(bool moveClockwise) {
if (!moveClockwise)
timeCounter += moveSpeed*Time.fixedDeltaTime;
else
timeCounter -= moveSpeed*Time.fixedDeltaTime;
float x = Mathf.Cos (timeCounter);
float y = Mathf.Sin (timeCounter);
transform.position = new Vector3 (distFromCentre*x, distFromCentre*y,0);
}
Also this seems to work fine as well:
transform.RotateAround (Vector3.zero,new Vector3(0,0,1),speed);
Now my question is how do i move my player using velocity? I was forced to keep my body as 'kinematic rigidbody2D' however I want my player to be a 'dynamic rigidbody2D'.
My reason for this is several: 1. Movement via velocity makes it independent of the timeCounter. 2. Dynamic Bodies enable collisionDetection. Hence it is basically a requirement for my game.
Thank you so much for taking the time to read this! Any suggestions or nudges in the right direction would be greatly appreciated and if you find anything wrong in my code or approach please comment!