- Home /
"Mouse Trap Boot" with touch screen not axis.
I basically have my code working the way i want. I can pull my boot back and when i release it kicks. But the issue i am having is getting it to work on an android touch screen instead of the horizontal axis. Any help would be greatly appreciated.
[code]using System.Collections;
public class Boot : MonoBehaviour {
public Vector2 touchDeltaPosition;
public Vector3 eulers;
public float force = 410.0f;
public float velocity;
public GameObject pivot;
public float speed = 0.1f;
void Awake() {
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
touchDeltaPosition = Input.GetTouch(0).deltaPosition;
}
velocity = Input.GetAxis("Horizontal") * 90;
//velocity = touchDeltaPosition.x;
Debug.Log(velocity);
TapSelect ();
}
void TapSelect() {
if(velocity < 0) {
pivot.transform.rotation = Quaternion.Euler(new Vector3(0, 0, velocity));
}
}
void OnCollisionStay(Collision collision) {
if (collision.rigidbody){
Debug.Log("Collision: " + collision + collision.collider.name);
collision.rigidbody.AddForce(new Vector3(force * 10, force * 10, 0));
}
else {
return;
}
}
} [/code]
Comment
If there is anything else i can show or describe to help fix this problem please let me know thanks.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
how can i stop rotation without stopping y axis 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
Game object z axis makes object not line up with parent 1 Answer