|
Hi guys! I'm trying to make a topdown 2D game so that I can learn Unity :) So far i've made the character, the map and some other stuff but i'm having trouble with the camera. How can i make the camera move only when the player moves the mouse to the sides of the screen, without the unit chasing/moving/rotating towards the mouse? P.S.:I tried finding other questions or close functions but i didn't find a lot of useful stuff/info.
(comments are locked)
|
|
Expanding on the comment : you need to check if the mouse position is within a certain distance from an edge, then affect your character accordingly. Have a look at Input.mousePosition , Screen.height and width : http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html http://unity3d.com/support/documentation/ScriptReference/Screen-height.html http://unity3d.com/support/documentation/ScriptReference/Screen-width.html : Create a New Scene, then Create a Cube. Attach this Script to the Cube and hit Play. Thakn you both, now I know how this works :)
Jun 16 '12 at 12:26 PM
hilchev
no problem (am same person btw =]). I forgot to include some GUI display stuff so you can see the mouse position relative to the screen. Add this to the end of the script :
Jun 16 '12 at 03:17 PM
alucardj
(comments are locked)
|

you need to check if the mouse position is near one of the edges, then affect your character accordingly. I am on my way out, but shall check this qn later. In the meantime, have a look at Input.mousePosition , Screen.height and width :
http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html
http://unity3d.com/support/documentation/ScriptReference/Screen-height.html
http://unity3d.com/support/documentation/ScriptReference/Screen-width.html
e.g.
I'm gonna experiment a little with those, but still, please do give an idea if you have one :) Тhank you for pointing me in the right direction.