- Home /
[Problem] Two Mobile Single Stick Controllers and Click Controls not working synonymous with each other
I'm attempting to have both of my mobile stick controllers that are working just fine, also be able to work at the same time with my clicker script so that I can move around and be able to select enemies or objects at the same time. This is the only problem that I haven't been able to figure out so far, if there is a problem with my code or you need any other information feel free to let me know, thanks!
FIRST SCRIPT
Ray ray;
RaycastHit hit;
void Update () {
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
clickers();
ispaused = TouchPlayerController.paused;
}
private void clickers()
{
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray, out hit, 100.0f))
{
if (hit.transform != null)
{
if (ispaused == false)
{
//Here are the selectable items
enemy1();
}
}
}
}
}
**SECOND SCRIPT**
void Update () {
h = CrossPlatformInputManager.GetAxisRaw("Horizontal");
v = CrossPlatformInputManager.GetAxisRaw("Vertical");
lh = CrossPlatformInputManager.GetAxisRaw("RightLeft");
//lv = CrossPlatformInputManager.GetAxisRaw("UpDown");
if (paused == false)
{
moveController();
}
}
void moveController()
{
h = h / speed;
v = v / speed;
player.transform.Translate(h, 0, v);
player.transform.Rotate(0.0f, lh * lookSpeed, 0.0f);
/**
* Bottom Code should keep the view point from being able to go past the point.
* Currently Edited in editor settings to only allow horizontal viewing.
* */
//Debug.Log("X =" + player.GetComponentInChildren<Camera>().transform.rotation.x);
//Debug.Log("Y =" + player.GetComponentInChildren<Camera>().transform.rotation.y);
if (player.GetComponentInChildren<Camera>().transform.rotation.x < 0.4f && player.GetComponentInChildren<Camera>().transform.rotation.x > -.4f)
{
player.GetComponentInChildren<Camera>().transform.Rotate(-lv, 0.0f, 0.0f);
}
else if (player.GetComponentInChildren<Camera>().transform.rotation.x >= 0.4f)
{
player.`enter code here`GetComponentInChildren<Camera>().transform.Rotate(-0.4f, 0.0f, 0.0f);
}else if(player.GetComponentInChildren<Camera>().transform.rotation.x <= -0.4f)
{
player.GetComponentInChildren<Camera>().transform.Rotate(0.4f, 0.0f, 0.0f);
}
}
Comment