- Home /
transform.position.y == touch position ??
I want an empty gameobject to have the same y position as where the mouse is on screen (or finger for touch input, wich i need since it's a mobile game)
Somehow i don't seem to find anything on answers, so that's why i ask. I hope someone knows how to do this, cuz i'm getting sick of days and days of trial and error, when i only get errors:P
The main problem is that i can't get the touch position to be a vector3 position.
Here's my current script: function Update () {
var TouchPosition : Vector3 ;
TouchPosition = Camera.main.ScreenToWorldPoint (Vector3.forward);
transform.position = TouchPosition;
}
Answer by Raymond 2 · Dec 25, 2011 at 08:38 PM
Okay never mind, got it working, with more trying and trying and trying, here's the code for those who are interested:
var cord : Vector3 ;
function FixedUpdate ()
{
cord = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Debug.Log(cord);
transform.position = cord;
transform.position.z = 0;
transform.position.x = 0;
}
Your answer
Follow this Question
Related Questions
transform.position 3 Answers
Aim Down Sights Positioning Problem 1 Answer
Place a object in front the camera in the coordinate 0 of Y axis 2 Answers
Change object position on trigger enter 3 Answers
Prevent changing position 1 Answer