Question by
zecbmo · Sep 27, 2015 at 12:46 PM ·
positionscreenmovemove an objectscreentoworldpoint
Move Object to the side of the Screen
I am working on making a mobile phone game and need to have a wall at each side of the screen. To get around the issue of different screen sizes I was going to move the wall to the left/right side to the camera.
Using this code
camera = GameObject.Find("Main Camera");
cam = camera.GetComponent<Camera>();
transform.position = cam.ScreenToWorldPoint(new Vector3(0,0,0));
I assumed it would move the object to the bottom left of the screen, but it isn't working. It ends up moving it to the right slightly.
Any tips or help would be great.
Comment
Your answer
Follow this Question
Related Questions
how to make a gameobject be positioned according to screen (on edge of screen)? 1 Answer
Vector2.MoveTowards Not Working 1 Answer
Player (box) movement is shaky (visual only) 0 Answers
Moving moving Object with left/right arrow keys in a circular direction 3 Answers
How to make an object not move through an wall using transform.translate? 3 Answers