The button works fine on Editor, but not on Mobile.
I'm quite new to unity, so i'm learning things that can help me out in Game Development, specifically Mobile Game Development.
I've done a couple of things, but making the buttons move the player has proven to be quite difficult due to my lack of knowledge.
Here is the script for the buttons:
public void TouchLeft()
{
MovePlayer.moveLeft = true;
}
public void UpLeft()
{
MovePlayer.moveLeft = false;
}
public void TouchRight()
{
MovePlayer.moveRight = true;
}
public void UpRight()
{
MovePlayer.moveRight = false;
}
I'm using Event Trigger to make use of the functions provided above, which they work fine in the Editor.
Here is the code for the movement script attached to the player:
void Update()
{
fasterPlayerUpgrade = PlayerPrefs.GetInt("FasterPlayerUpgrade", 0);
if (moveRight == true)
{
gameObject.GetComponent<Rigidbody>().MovePosition(transform.position + transform.forward * 4f * fasterPlayerUpgrade * Time.deltaTime);
}
if (moveLeft == true)
{
gameObject.GetComponent<Rigidbody>().MovePosition(transform.position + -transform.forward * 4f * fasterPlayerUpgrade * Time.deltaTime);
}
}
I can't seem to find the issue here, i'd be quite grateful if someone helped me out and pointed me in the right direction.
Your answer
Follow this Question
Related Questions
Is this bug known? function parameter s and if statements c# 1 Answer
Load Scene Unity by Application.LoadLevelAsync 0 Answers
Mesh colliders stop working after exporting to iOS device. 0 Answers
How to call functions from another script c# (Unity5) 1 Answer
[SOLVED]My code line don't execute 1 Answer