Link:https://academo.org/demos/rotation-about-point/
private bool isTiming = false;
private float timeTillKeyIsPressed = 0;
float time = 1;
float time2 = 4;
void Update()
{
if (isTiming)
{
if (timeTillKeyIsPressed <= time) //0<=1 1<=1
{
if (time2 != 0) //4!=0 4!=1 4!=2 4!=3 4!=4
{
time2 -= Time.deltaTime;
float angle = 360; // reset here but not work properly
rb.transform.Rotate(Vector3.forward * angle * Time.deltaTime / time);
}
}
}
public void Rotate(float angle)
{
float d = angle * Time.deltaTime;
int movement = GetMovement();
rb.transform.Rotate(Vector3.forward * d * (float)movement * speed);
}
public int GetMovement()
{
if (Input.touchCount > 0) //mobile //how many count touch
{
Touch touch = Input.GetTouch(0);
float num = (float)(Screen.width / 2);
var touchres = touch.position.x;
//DebugPanel.Log("touchres", "touchres:" + touchres);
var res = touchres > num;
//DebugPanel.Log("res", "res" + res);
if (res)//TRUE(Right)
{
return -1;
}
else//FALSE(Left)
{
return 1;
}
}
else
{
return (int)Input.GetAxisRaw("Horizontal") * -1; //pc
//return 0;
}
}
void OnTriggerEnter2D(Collider2D other) //here my obstacle touch my player
{
foreach (Transform child in transform)
{
if (child.tag == "point")
{
isTiming = true;
}
}
}
Image:
when I m playing the game:
I want the:
Player Image:
I want the when my player touches my obstacle then I want to reset the position of my player??
I hope my question is understood.