In this project you should set up a camera and an object you want the player to be able to move. Create a script and attach it to the object you want to move and open the script.
The first this we do is add the following line to the update method.
The first this we do is add the following line to the update method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3 screenPosition = | |
Camera.main.WorldToViewportPoint(transform.position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float posX = screenSpace.x * maxX; | |
float posY = screenSpace.y * maxY; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float maxX = Screen.width - pixelWidth; | |
float maxY = Screen.height - pixelWidth; |
No comments:
Post a Comment