Hi
First, thanks to anyone who has posted in these forums. It’s been a week for me now and I’ve learned so much and have borrowed code, played with it, tweaked here and there, and have drunken about 100 cups of coffee - and have enjoyed every moment.
So, here is my current problem. Have been sitting on this problem for a day now and searched the forums, but I can’t seem to find a viable solution.
Action 1:
I have 3 Prefab Objects spawning from one spawn point randomly. This works fine.
Action 2 - PROBLEM 1.
I want to be able to move each of these spawned objects to any position on screen. I have the drag/move script working fine for this. However, and this is the question/problem, when i touch a spawned object, it moves as planned, but then as soon as another object spawns, it attaches itself to the object I’m currently moving, if you get the drift.
PROBLEM 2
If i click on a place on screen anywhere BUT on the object itself and drag on the screen with the finger it will jump to that position (start of drag). Trying to find a solution now for it (if it’s obvious to your more-qualified eyes in the code above please let me know
)
Is it something to do with the line “iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved)” ? is this saying that until the finger starts moving, that’s when it will move the object? (but it does so from anywhere on screen rather than from the object itself.)
//Drag the Spawned Object Enemy across 3D plane======
//var enemyselect : Transform; (NB: I used to have this in there until i realised it had no effect. In the inspector on the prefab object i would choose the prefab itself - but i need a way for the touch to register ONLY on each spawned object individually.)
var hit : RaycastHit;
function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
for (touch in iPhoneInput.touches) {
if (Physics.Raycast (ray, hit, 100)) {
if (iPhoneInput.touchCount > 0 iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved) {
transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x,touch.position.y,10));
}
}
}
}
Thanks for any advice you can give. And remember, I’m a complete noob!