- Home /
Why does this script I got from the Unity Document site does not work?
I got the error: "Assets/Scripts/_pistolAI.js(7,47): BCE0019: 'GetTouch' is not a member of 'UnityEngine.Input'. Did you mean 'GetKey' ?"
http://unity3d.com/support/documentation/ScriptReference/Input.GetTouch.html
// Shoot a ray whenever the user taps on the screen
var particle : GameObject;
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray)) {
// Create a particle if hit
Instantiate (particle, transform.position, transform.rotation);
}
}
}
}
Does anyone know why or if there is a fix? Can you help me fix it
Answer by Eric5h5 · Dec 09, 2010 at 05:30 AM
It works fine. I guess you're using an older version of Unity iPhone, in which case you should use the documentation that came with it instead of the online docs (which are always going to be for the most recent version), since Input was handled somewhat differently then. Or upgrade.
I have Unity 1.7? What version are you using? What is the fix?
Unity 3.1. I already told you the fix: use the documentation that came with Unity iPhone 1.7.
Okay, do you have a link to the 1.7 documentation? I see no option to read the old versus the new. I googled for the old docs. Perhaps I'll ty the forum and see if maybe someone knows. Thanks for the help mate.. It's frustrating sometimes - but we'll all get there
Once again, you need to use the documentation that came with Unity iPhone 1.7. There is no link to it, it's on your hard drive, in the folder called Documentation.
Thanks mate.. all I need was the correct syntax "iPhoneInput.GetTouch" From a learning perspective it's good you did not give me the solution..