Question by
sbalaiyawala · Mar 08, 2020 at 02:37 PM ·
playertouchcircular
I am new to Unity and i want to rotate my player in circular motion using touch buttons on android but cant. Please help
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class playertwo : MonoBehaviour
{
public float movespeed = 600f;
float movement = 0f;
private float screenwidth;
private void Start()
{
screenwidth = Screen.width;
}
// Update is called once per frame
void Update()
{
int i = 0;
while (i < Input.touchCount) ;
{
if(Input.GetTouch(i).position.x> screenwidth/2)
{
Runcharacter(1.0f);
}
if(Input.GetTouch(i).position.x< screenwidth/2)
{
Runcharacter(-1.0f);
}
++i;
}
}
private void Runcharacter(float HorizontalInput)
{
transform.RotateAround(Vector3.zero, Vector3.forward, movement * Time.fixedDeltaTime * -movespeed);
}
private void OnTriggerEnter2D(Collider2D collision)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
Comment
Your answer
Follow this Question
Related Questions
Help with moving the player with Input.touches 0 Answers
Separate Input from Touch on GUI 0 Answers
Move an object in a circular path according to touch position 1 Answer
What this error? 0 Answers
The shooting mechanics 0 Answers