- Home /
Question by
santyarellano039 · Mar 05, 2017 at 03:26 PM ·
2d gametouch
How to get touch.position in Unity "units"?
Well, I'm making a 2d Game (Orthographic camera) and I want to instantiate objects where the screen is touched by the player. The thing is that the position that I get when I touch the player is in pixels for some reason... What can I do?
This is my code
int fingerCount = 0;
foreach (Touch touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) {
fingerCount++;
}
if (fingerCount > 0) {
//crear huevo
print (touch.position.x + ", " + touch.position.y);
//Instantiate(huevo, new Vector3(touch.position.x, touch.position.y, 0), Quaternion.Euler(0, 0, 0));
}
}
Comment
Your answer
Follow this Question
Related Questions
How to make a projectile in the finger/mouse position in a 2D endless runner? 0 Answers
Global input script vs own scripts for all gameObjects 0 Answers
HOW TO MAKE A 2D OBJECT MOVE WITH TOUCH INPUT ON ANOTHER 1 Answer
Touching moving sprites 0 Answers
simple 2D controller for touch screens (arrows left/right/up/down) 1 Answer