• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by BertMDTV · Nov 27, 2014 at 06:10 PM · first-person-controlleraimingy-axisx-axisgta

GTA Style Aiming

So I have a player that has a good Mecanim, a nice SmoothFollow camera, a zoom script that zooms the camera in like an aim down sights t$$anonymous$$ng, and the MouseLook script (that I took from Unity's First Person Controller) that revolves the x axis of the player. The problem I am having is when you right click (aim down sights) the camera zooms in properly but I can't get the camera to move on the Y axis, it only moves left and right.

I did try doing what Unity's First Person Controller does and have the X axis MouseLook script on the player and then have the Y axis MouseLook script on the Main Camera but, of course, that didn't work.

If anyone can help me find an what so that when I aim down the sights the camera will be able to move on the x and y axis that would be great.

If you have any other ideas on how I could do it that would be awesome to.

Thanks in advance

Edit : additional information

The first picture shows my $$anonymous$$erarchy with the player and the Main Camera. The Second picture shows my player script with the MouseLook Script attached to it on the X Axis. The t$$anonymous$$rd picture shows the Main Camera pictures with the MouseOrbit script and the Zoom Script.

I removed the Smooth Follow script but haven't tried using the MouseLook Script on the Y axis to see if the Smooth Follow was locking it, ill try it now.

What I am trying to do now it putting a cube in front of the player to see if it will stop the Mouse Orbit Script from revolving all around the player so it will stay be$$anonymous$$nd $$anonymous$$m and I have control of the x and y axis with it but it is kind of struggling.

alt text

playerhierarchy.png (78.5 kB)
Comment

People who like this

0 Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Nov 27, 2014 at 06:35 PM 0
Share

From memory, that script has an enum with a value use X and Y, try that. Look where you got the script from, the charctrlr has 2 MouseLook scripts. One on the parent with the collider (controls Y), and one on the childed camera (controls X). So set yours to do both, if I'm wrong, add 2 scripts on your camera (for separate X and Y)

avatar image BertMDTV · Nov 27, 2014 at 06:56 PM 0
Share

I tried to add a mouse and a mouse y script to the main camera and I only controller the mouse x. Do you want me to add the code so you can see it and Im a little confused on what you said in the first sentence

avatar image AlucardJay · Nov 27, 2014 at 07:24 PM 0
Share

First to clarify: all your zoom script does is (guess) changing the FOV; it does not handle any rotations?

  • can't get the camera to move on the Y axis, it only moves left and right* : do you mean that you cannot get it to move on the X axis(up/down with mouse, rotates/tilts gameObject on the X)?

I think you need to edit your question with more information on what script is attached to what gameObject in your player prefab, and the parent-child relationships of those gameObjects. A screenshot of your player in the hierarchy and all the children expanded would help.

Edit : derp, forget that!

You have a SmoothFollow script, does this restrict the Height of the camera in relation to the target object? I think the SmoothFollow is overwriting your Look up/ down.

avatar image BertMDTV · Nov 28, 2014 at 06:24 AM 0
Share

Well here are the pictures that you asked for alucardj (sorry for the bad pictures)

The first picture shows my hierarchy with the player and the Main Camera. The Second picture shows my player script with the MouseLook Script attached to it on the X Axis. The third picture shows the Main Camera pictures with the MouseOrbit script and the Zoom Script.

I removed the Smooth Follow script but haven't tried using the MouseLook Script on the Y axis to see if the Smooth Follow was locking it, ill try it now.

What I am trying to do now it putting a cube in front of the player to see if it will stop the Mouse Orbit Script from revolving all around the player so it will stay behind him and I have control of the x and y axis with it but it is kind of struggling.

avatar image BertMDTV · Nov 28, 2014 at 06:25 AM 0
Share

alt text

screen shot 2014-11-28 at 1.14.33 am.png (40.6 kB)
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by BertMDTV · Nov 28, 2014 at 11:17 PM

ok well I figured some stuff out. So what I did is removed the SmoothFollow and only left the MouseOrbit. What I made the MouseOrbit do is always stay be$$anonymous$$nd the player so actually I can move it in each direction, w$$anonymous$$le still looking be$$anonymous$$nd the player, and the zoom script workings fine.

Basically the only problem I am having now is I cant get the head and the upper body to look where it is aiming. I have it so that is plays the aiming animation when I right click but when I move all around the head and upper body don't follow they just face forward.

Any ideas?

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

GTA Style Aiming 0 Answers

up and down detect 1 Answer

Restrict camera rotation in x and y? 1 Answer

Making a Paddle Move Vertically? 1 Answer

How can i Limit the movement of character (x, y axis) on camera view 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges