i’m having some problems with this next stage that i’m on. I have been using MouseButtonDown but i can only pop one ball at a time. i have been looking up on multi touch and what they say just goes over my head multi touch 4 loop and hit test? i am having trouble understanding the code to go with it. what i need to happen, instead of one touch i need two at the same time.
MY CODE
#pragma strict
var tapCount : int;
var Health : int;
function start()
{
Health = 1;
}
function OnMouseDown()
{
Health -= 1;
Destroy (gameObject);
}
function OnDestroy (){
tapCount += 1;
}
these are place on the balls themselves so when i touch them with mouse or touch they destroy themselves. if i could have yours guys help i would really appreciate it, love you all!!!
Here’s an incomplete snippet for you to look at:
function Update()
{
if (Input.touchCount > 0 && touchEnabled)
{
var theTouch : Touch = Input.GetTouch (0);
// Cache Touch (0)
var ray = Camera.main.ScreenPointToRay(theTouch.position);
if(Physics.Raycast(ray,hit,450,layerMask))
{
if(Input.touchCount == 1)
{
if (theTouch.phase == TouchPhase.Began)
{
startVector = ray.GetPoint(1);
wasRotating = false;
}
if (theTouch.phase == TouchPhase.Moved)
{
moveVector = ray.GetPoint(1);
targetItem.transform.Rotate(0, 0, turningAngle,Space.World);
moveAngle = 0;
startVector = moveVector;
}
//ETC
Basically, if there’s more then 0 touches, shoot a ray from that position. For touch number 1, at the start do something once If its moving, do that etc. Just fill in your own stuff, in Began, Moved, Stationary, Ended and Canceled phases.