Hi all, thanks for any help-
I have a very basic game you can player here:
http://ofgabriel.com/earthdefense/EarthDefense_Gold_2.html
I am working on getting it to the iPad/iPhone, however having an issue with touch, where it seems to just randomly select asteroids on touch, instead of the one you press on.
There is only one bit of script that will use touch (other than GUI, which works fine), and it is running on the asteroid thusly:
function Update ()
{
//movement and rotation...
transform.Translate(0,asteroidSpeed * Time.deltaTime,0);
asteroidMesh.transform.Rotate(rotateXSpeed * Time.deltaTime, rotateYSpeed * Time.deltaTime, rotateZSpeed * Time.deltaTime);
//Code to start "atmosphere entry" particle effect, need to be moved to a trigger...
if(transform.position.y <= .736)
{
particleFX.emit = true;
}
//this is the new code I TRIED to make work, but utterly failed, lol...
for (var i = 0; i < iPhoneInput.touchCount; ++i)
{
if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Began)
{
// Construct a ray from the current touch coordinates
var ray = Camera.main.ScreenPointToRay (iPhoneInput.GetTouch(i).position);
if (Physics.Raycast (ray))
{
if (levelMasterScript.gameActive levelMasterScript.currentTarget != gameObject)
{
levelMasterScript.TargetNewAsteroid(gameObject);
levelMasterScript.staticEquationPosition = camera.main.WorldToScreenPoint (transform.position);
if (levelMasterScript.staticEquationPosition.y <= 172)
levelMasterScript.staticEquationPosition.y = 172;
if (levelMasterScript.staticEquationPosition.y >= 620)
levelMasterScript.staticEquationPosition.y = 620;
}
}
}
}
}
As you can probably see, I tried to take the code directly from the script reference, but apparently missed something important or just messed it up. I can’t find the issue though…arg. This is probably an extremely obvious fix to anyone who uses iPhone touch code on a daily basis, but it’s new to me.
If somebody could suggest the proper bit-o-code, would be MUCH appreciated, this is last piece I need working before I call this game done