x


Help with code logic iPhone Touch FPS

How do I make this script fires a projectile in the z axis? I tried adding: transform.position.z that did not work.

function Update () { for (var i = 0; i < iPhoneInput.touchCount; ++i) { if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Began) { clone = Instantiate (bullet, transform.position, transform.rotation); audio.PlayOneShot(pistolsfx);

} } }

How do i get it to shoot the projectile where I tap? This the script used to create the crosshair.

function OnGUI() {

var pos = iPhoneInput.GetTouch(0).position; var texRect = new Rect(pos.x - reticle.width / 2, pos.y - reticle.height / 2, reticle.width, reticle.height);

GUI.DrawTexture(texRect, reticle);

}

The crosshais only show up when I touch the screen. How to fix this and make projectile fire at the point where I touch the screen...

Thanks for your help in advanced

more ▼

asked Dec 10, 2010 at 02:03 AM

pixelboi gravatar image

pixelboi
13 6 4 6

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2230
x1642
x1189
x70

asked: Dec 10, 2010 at 02:03 AM

Seen: 1577 times

Last Updated: Dec 10, 2010 at 02:03 AM