i have a gameobject and i can swipe it left and right but when i swipe faster the collision is not detected i even tried putting continuous Dynamic in each object but it is still going through objects i’ll attach my swipe script below and i 'm using Easytouch asset for overall touch inputs and here’s the swipe script.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using HedgehogTeam.EasyTouch;
public class Swipe : MonoBehaviour {
// public GameObject trail;
// public Text swipeText;
public Vector3 temp;
public float swipeforce;
// Subscribe to events
void OnEnable(){
EasyTouch.On_SwipeStart += On_SwipeStart;
EasyTouch.On_Swipe += On_Swipe;
EasyTouch.On_SwipeEnd += On_SwipeEnd;
}
void OnDisable(){
UnsubscribeEvent();
}
void OnDestroy(){
UnsubscribeEvent();
}
void UnsubscribeEvent(){
EasyTouch.On_SwipeStart -= On_SwipeStart;
EasyTouch.On_Swipe -= On_Swipe;
EasyTouch.On_SwipeEnd -= On_SwipeEnd;
}
// At the swipe beginning
private void On_SwipeStart( Gesture gesture)
{
// swipeText.text = "You start a swipe";
temp = gesture.GetTouchToWorldPoint(5);
}
// During the swipe
private void On_Swipe(Gesture gesture)
{
//Snake_Controls.Instance.isDied = false;
// the world coordinate from touch for z=5
Vector3 position = gesture.GetTouchToWorldPoint(5);
float te = position.x - temp.x;
Vector3 v3 = transform.position;
// float deltaMousePos = Mathf.Abs(te);
//float sign = Mathf.Sign(te);
//BodyParts[0].Translate(Vector3.left * rotationSpeed * Time.deltaTime * deltaMousePos * sign);
//Snake_Controls.Instance.tail[0].GetComponent<Rigidbody>().AddForce(Vector3.right *-10 * deltaMousePos * -sign);
v3.x += te*swipeforce/1.2f ; //Manage speed here
v3.x = Mathf.Clamp (v3.x,-17.8f, 17.8f);
//Camera.main.transform.rotation = Quaternion.Euler (new Vector3 (15,0,(v3.x *7f)));
transform.position = v3;
temp = position;
}
// At the swipe end
private void On_SwipeEnd(Gesture gesture)
{
// Get the swipe angle
// float angles = gesture.GetSwipeOrDragAngle();
//swipeText.text = "Last swipe : " + gesture.swipe.ToString() + " / vector : " + gesture.swipeVector.normalized + " / angle : " + angles.ToString("f2");
}
}
Any help or Suggestion ?