Using Unity 4.1.2, using C# mono, Android Development.
Hi guys Ive created the following script.
using UnityEngine;
using System.Collections;
public class ButtonLeftMove : MonoBehaviour {
// Use this for initialization
public float MoveSpeed = 10;
private float min = -20f;
private float max = 20f;
void Start () {
}
// Update is called once per frame
void FixedUpdate ()
{
MoveSpeed = 50F;
GameObject joeblob = GameObject.FindGameObjectWithTag("playertag");
if(Input.touches.Length > 0)
{
Debug.Log ("Touched");
joeblob.rigidbody.AddForce(Vector3.left * MoveSpeed);
//rigidbody.AddForce(Vector3.right * MoveSpeed);
}
Vector3 clampVel = joeblob.rigidbody.velocity;
clampVel.x = Mathf.Clamp(clampVel.x, min, max);
joeblob.rigidbody.velocity = clampVel;
}
}
Works great, object moves when the screen is touched, however this is true for any part of the screen.
this script is attached to my GUI texture, i only want it to be true if the GUI texture is touched Not anywhere on the screen!
what extra code am I missing?
cheers