Changing a variable from a different method
Hello, I'm new to both unity, and the world of programming. I've been working on my first game in unity. I'm trying to convert a premade controller I found to have touch screen abilities. After watching a few tutorials on youtube I found the easiest way to do this is by using a second script (Touch controller) The Player controller I'm using however is far more complex then those used in the tuts so I'm very lost on what I'm doing.
public void ProcessInput()
{
float inputAxisX = Input.GetAxis("Horizontal");
if (inputAxisX == 0)
{
Debug.Log("AxisX = 0");
}
else
{
Debug.Log("Moving! " + inputAxisX);
}
bool isKeyDownJump = Input.GetButtonDown
("Jump");
bool isKeyDownLeft = inputAxisX <-.5;
bool isKeyDownRight = inputAxisX > .5;
This seems to be the most important code when it comes to input. I need a way to change the inputAxisx from a different method that I named move for the player to move when my on screen buttons are touched with unitys built in event trigger system with pressdown, and pressup
public void Move()
{
}
But I'm not sure how to go about this.
Your answer
Follow this Question
Related Questions
2D Weird Jumping 1 Answer
Problem in raycast to detect touch in 2D game 1 Answer
Camera Positioning When Following Character 0 Answers
Problem With a Multi-Jump C# script, robot 2d character controller 1 Answer
Unity2d-Android-C#: How to convert current movement script to be used for touchscreen? 1 Answer