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