- Home /
Camera move on mouse click
I am rather new to unity and coding myself. Trying to learn it but I am coming across a problem. The question I have may have been answered in another location. Sorry if this is a repeat question.
The game I am making to try things out in is a naval type game. The character is a battleship. What I am trying to do right now is make the camera look at the mouse when the right mouse button is clicked. However I want the turrets to follow the mouse.
I tried to built in mouselook script and played with it a little, but its not giving the results I am looking for.
Answer by timsk · Sep 27, 2011 at 09:24 AM
Why not just take the standard mouselook script and add something like:
if(Input.GetMouseButtonDown(1))
{
//rest of script here
}
all you need to get it to do is check if the right mouse button is held; then run the mouselook code.
Tried posting an answer but it just got deleted and don't want to repost in case double posting.
I tried the code you suggested but it gave me a compiler error. Tried using it in different parts of the code but it still gives me the error.
Not very code literate.
Your post didn't get deleted. Please read up the sites rules.
"it gave me a compiler error" gives me absolutely no information i can use to help you.
I would suggest getting a book or 2 (or even watching some tutorials online) on coding. There are plenty of resources pointing to good program$$anonymous$$g learning material.
Compiler errors can be surprisingly useful! Look carefully at the error console, and see if you can get some clues as to what is going wrong.
Answer by chomper357 · Sep 27, 2011 at 09:47 PM
I tried putting that code you suggested in, but it is giving me a compiler error. I tried using it in different places of the code but it is still giving me an error. I am not very code literate.