2 Fingers touching 2 objects

Hi. I have small problem. Here is my script:

function Update () {
	var hit : RaycastHit;
for (var evt : Touch in Input.touches)    
{
					var ray = camera.main.ScreenPointToRay(evt.position);
					
if ( Physics.Raycast(ray, hit, 100)   Input.touchCount == 2  hit.collider.name == ("styk")  hit.collider.name == ("aura"))
{
Debug.Log("ok");
}
}
}

Let’s say i have 2 box colliders (1 named: styk the other: aura). I want to recieve “ok” on my console constantly when both are touched in the same time. Currently when i change code for example to:

if ( Physics.Raycast(ray, hit, 100)   Input.touchCount == 1   hit.collider.name == ("aura"))

and tap only “aura” object then i receive “ok” info.
When trying to touch 2 objects with first the script - it doesnt work. What’s wrong with it?
I guess it’s because of having only single variable

	var hit : RaycastHit;

so when i tap first object then variable “hit” have hit from first object, and when i tap second object, then variable hit change it’s parameter. So it cant work together.
I think i must use array for this, something like:

	var hits : RaycastHit[];
for (var i = 0;i < hits.Length; i++) {
        var hit : RaycastHit = hits[i];
......
}

But i dont know how it should be exactly made.
Some bell’s are ring i but i dont know in which church :shock:

Or maybe there are other methods how i can check if those 2 objects are touched in the same time?
Thanks

Use the Touches collection, verify that there are multiple touches, then raycast from each touch position.

At least, that’s where I would start.

edit I just realized you are doing that, I didn’t see it at first. What appears to be happening is that you are storing the first touch, then clearing it and storing the 2nd.

ray should be an array, you should increment manually, then loop through the array.

for (evt : Touch in Input.Touches)
{
ray[i] = camera.main.ScreenPointToRay(evt.Position);

i++;
}

or something simular.