Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How could i go about creating a custom camera script?

Discussion in 'Scripting' started by Nullie, Jun 4, 2013.

  1. Nullie

    Nullie

    Joined:
    Jun 4, 2013
    Posts:
    4
    I'm a little new to scripting, a general explanation of the functions i would need to use and/or a finished script with comments and outlines i could walk through myself would be useful (im not asking for free scripts, i'd probably edit and customize any if i got one to my tastes anyways.)

    What i want is probably easiest explained using pictures. So here we go, crappy arts:

    $75029023.png

    Woah, that turned out worse than i thought. xD anyways, the camera would roll backwards and look up when the mouse was moved until a certain point, and would roll forwards looking down, rather than just rotating to see more, it would move, more closely simulating a persons head when they look up or down, how could i accomplish this without using built in packages and scripts?

    I'f this isn't very clear tell me what i should clarify so that its easier to understand. thanks ^u^

    -nullie
     
    Last edited: Jun 4, 2013
  2. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    You could use the default cam scripts, and all other cam scripts available for a reference to create your own. If you don't know how to script very well then perhaps tutorials would be your best bet.

    Also the collaboration sector of the forum is a great place to get custom work done for money or trade.

    The MouseLook script is pretty basic and does what you're asking.
     
  3. snortop

    snortop

    Joined:
    Dec 16, 2011
    Posts:
    194
  4. Nullie

    Nullie

    Joined:
    Jun 4, 2013
    Posts:
    4
    snortop, you think i didnt already google that? what i found wasn't helpful. which is why im defining what im looking for more clearly.

    the mouselook script isn't very helpful in terms of documentation etc. and doesnt help me with the movement i need, just rotation, which i am already capable of doing, which is why im not looking for help in that.
     
  5. snortop

    snortop

    Joined:
    Dec 16, 2011
    Posts:
    194
    Well then you could have said so in the message.
    Soo it wasent clearly in the message.

    The seach on google gave lots of tutorials on fps movement script.

    In the picture it show that you looking for something that rotate the camera up and down. Which the fps movement script does.

    What you want the documentation to say, when you sound like you already know have to do it.
     
  6. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    If I understood right you want to rotate the camera on an off-center axis. You could do it easily by making the camera object a child of other object that you rotate and has it's pivot in neck's position, then set the camera's pivot to the eyes' position. This should give you the slight movement when rotating the parent object of the camera.
     
  7. Nullie

    Nullie

    Joined:
    Jun 4, 2013
    Posts:
    4
    Thank you! that would work. :D
    but i still dont know how to script it...
     
  8. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    Then you would use the stock mouselook script on the parent object ;)