I've been trying to add touch controls to my game, and am having a bit of a problem with movement on the horizontal axis. Here is the relevant code:
**In Player Controller Script**
public void Jump()
{
GetComponent ().velocity = new Vector2 (GetComponent ().velocity.x, jumpHeight);
}
public void Move(float moveInput)
{
GetComponent ().velocity = new Vector2 (moveSpeed * moveInput, GetComponent ().velocity.y);
}
**In a separate Touch Controls Script**
private PlayerController Player;
void Start () {
Player = FindObjectOfType ();
}
public void LeftArrow()
{
Player.Move (-1);
}
public void RightArrow()
{
Player.Move (1);
}
public void UnpressedArrow()
{
Player.Move (0);
}
public void Jump()
{
Player.Jump ();
}
This is the Event Trigger for my Jump button (My jumping works)
![Jump Event Trigger][1]
This is the Event Trigger for my Move Left button, which is the same as my Move Right button but in reverse (Neither moving left nor right works)
![alt text][2]
I think it may have something to do with the Pointer Up that is on the horizontal movement buttons, but I am not sure and have no idea how to fix it if that is the problem. Any help is appreciated.
[1]: /storage/temp/49103-game-prob-2.png
[2]: /storage/temp/49104-game-prob.png
↧