Hello,I started making an android game with unity and Im kind of stuck at making the character move.Im using GUI Textures to move the character.For example,to move right I use this script which I attach to the GUI Texture placed on the right of the screen :
var Player : Transform;
var CharacterSpeed = 5.0;
function OnMouseDown () {
Player.transform.Translate(Vector3.right * CharacterSpeed * Time.deltaTime);
}
The problem is that it only pushes the object a little bit.What I want is a smooth movement. Im new in unity and in scripting.I also am not familiar with ontouch fazes. Is there any way to do it with the OnMouseDown function ?
Thank you.
Edit :
Oh,and if I change the script into this :
var Player : Transform;
var CharacterSpeed = 5.0f;
function Update () {
OnMouseDown();
}
function OnMouseDown () {
Player.transform.Translate(Vector2.right * CharacterSpeed * Time.deltaTime);
}
Then the character moves constantly.
Edit 2 :
When I changed the OnMouseDown to OnMouseOver and I click on it(on my android phone) the character/object won’t stop. P.s. I noticed that if I click on the GUITexture then click somewhere else on the screen then the player stops.I assume that’s because the OnMouseOver is not being called anymore.