- Home /
HELP WITH SETTING
HI, I NEED HELP! I DON'T KNOW HOW TO SET THIS MOVEMENT! I GOT THIS CODE : using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.EventSystems;
public class leftmovement1 : MonoBehaviour, IEventSystemHandler {
public GameObject character;
public float maxSpeed = 10f;
bool buttonHeld = false;
public void pressed (BaseEventData eventData)
{
buttonHeld = true;
}
public void notpressed(BaseEventData eventData)
{
buttonHeld = false;
}
void Start ()
{
character = GameObject.FindWithTag ("Kowboys");
}
public void Update()
{
if (buttonHeld)
{
// Do stuff
Debug.Log ("click");
// Move Character
character.GetComponent<Rigidbody2D>().velocity = Vector3.right * maxSpeed;
}
else
Debug.Log ("not click");
}
} HOW TO SET THE PLAYER AND BUTTON TO MOVE??
$$anonymous$$aybe you could state, what you are actually trying to do. Explain the scenario a bit, please. From what I see, I can only estimate that you are trying to respond to some kind of input. $$anonymous$$aybe wanna check out the Input-Class? --> http://docs.unity3d.com/ScriptReference/Input.html
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
I want OnClick to fire the same frame that the button is clicked 1 Answer
using mouse to move an object 2 Answers
Player not following touch after camera is rotated? 0 Answers