Is there a way I can get the touch position of only the finger that FIRST touched a certain collider?
For example,
When I touch a collider, it will get the position of that touch.
And when I touch the same collider again with a different finger AND I haven’t let go of my first touch, it will just ignore the 2nd touch, and I should only have the position of the first initial touch.
EDIT:
Only the first touch that hits the collider, not the actual first touch on the whole screen.
Input.GetTouch(0) kind of gets the actual very first touch.
So if the player hits the collider on the second touch, then it’s (1), but it’s the FIRST touch on that certain collider, even though in actuality, it’s the second touch.
I’m not sure how to do this, I’m still kind of new to touches and stuff.
The current code I use returns the position of the first and second touch.
So when I touch something, it will get that position, and when I touch it again, the position will change, as if it’s combining both positions.
This is just an assumption though, I’m not sure if that’s really the problem.
Here it is just in case: It’s a joystick I use in moving my character.
Whenever I just touch it once, it will do its work properly, But when I touch it again with another finger, my character speeds up, and there’s no script that when I touch it twice, it will speed up. So I assumed it combining the position of the first and second, thus making my player move faster when I’m touching the same collider twice.
And yeah, it’s not using anything that has to do with fingerIDs, because I’m still not sure how to use it in this situation.
void Update () {
//Handles touches
for(int i = 0; i < Input.touchCount; i++)
{
Touch touch = Input.GetTouch(i);
Ray ray = GUICamera.ScreenPointToRay(Input.touches*.position);*
_ touchPosition = Input.touches*.position;*_
* if(Physics.Raycast(ray, out hit) && hit.collider.tag == “joystickTag”)*
* {*
* //the position of where the player touched*
* touchPosition = GUICamera.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 72));*
* //where you want to be (according to MoveTowards)*
* Vector3 desiredPosition = touchPosition;*
* //your clamp is relative to this position*
* Vector3 origin = centerPos.position;*
* //this vector points from ‘origin’ to ‘desiredPosition’*
* Vector3 diff = desiredPosition - origin;*
* //clamp the difference, then add it to the origin*
* transform.position = origin + Vector3.ClampMagnitude(diff, maxRange);*
* tempDelta = new Vector3(transform.position.x - oPos.x, -72, transform.position.z - oPos.z).normalized;*
_ delta = Vector3.Lerp(delta, tempDelta, Time.deltaTime * 8.0F);_
* }*
* }*
//This moves my player
_ player.transform.Translate(((Vector3.forward * delta.z) * playerSpeed) * Time.deltaTime);
player.transform.Translate(((Vector3.right * delta.x) * playerSpeed) * Time.deltaTime);_
}
Again though, I’m still not quite sure why it’s going fast.
Thanks!
EDIT: Still need some help.