Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by CypherGames · Jul 15, 2014 at 01:31 AM · cameramovementfpsguninheritance

FPS Gun Attached To Camera Weirdness

Hello there! I have been having a problem lately with all of my Unity FPS projects. When I attach a gun to my main camera and look up, the gun moves up too much. This also happens when I look down. No scripts attached to the gun. I'll show you some pictures. Please help!!

When looking up

When looking down

Comment
Add comment · Show 2
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 Albert-han · Jul 15, 2014 at 02:08 AM 1
Share

I think its because your gun is quite long maybe?Try using a model ins$$anonymous$$d of a capsule.It would make things easier to see.

avatar image CypherGames · Jul 15, 2014 at 03:13 PM 0
Share

The same thing happens with pistols, and the game is single player, so a model for the player would just add lag.

3 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by welwiz1 · Oct 19, 2016 at 09:03 PM

just so people know, all you have to do is make your players scale the same in all axis and it fixes this problem

Comment
Add comment · Show 1 · 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
avatar image N-8-D-e-v · Jun 23, 2020 at 04:09 PM 0
Share

this helped soooooo much

avatar image
2

Answer by brabbani · Dec 28, 2015 at 02:11 PM

The question is quite very old but I stuck up with the exact same problem and my issue was appeared because I changed the Scale-Y value in Transform of inspector of Player (First Person Controller), from 1 to 1.5. When I revert it to Scale-> 1, 1, 1 then everything start working fine.

Comment
Add comment · Show 1 · 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
avatar image ishdagz · Jul 21, 2016 at 01:45 PM 0
Share

Thanks for the comment, just fixed me problem

avatar image
0

Answer by Anti-Social Fred · Jul 15, 2014 at 03:46 PM

If it's moving up and down too much, then the only solution is to dampen the rotation. You CAN still maintain the relationship between parent-child / camera-weapon, but I would prefer doing something more along the lines of creating a separate script to manage rotation based off of the Camera.main.transform.rotation / eulerAngles, and unparenting the weapon completely.

The finished code should look something like:

             private Transform _cameraTransform = null;          // Caches the Camera's transform.
 
             GameObject _currentWeapon = null;           // Current weapon that's being used
             Transform _playerTransform = null;          // Player's Transform
             bool _canRotateWeapon = true;               // Can you rotate the weapon?
             float _rotationDampener = 0.5F;             // The amount that you want to multiply the rotation by. If it's rotating too much, keep this number < 1
 
             void Start()
             {
                 _cameraTransform = Camera.main.transform;
             }
 
             void Update()
             {
                 UpdateWeaponRotation(); 
             }
 
             // Updates the weapon's rotation
             void UpdateWeaponRotation()
             {
                 if (_canRotateWeapon && _currentWeapon != null)           // If there's currently a weapon and you can rotate the weapon
                 {
                     Vector3 desiredRotation = new Vector3(_cameraTransform.eulerAngles.x * _rotationDampener, _playerTransform.eulerAngles.y, _playerTransform.eulerAngles.z);   // Sets the rotation based off of the dampener * the Camera's X-axis. It might be the Z-axis instead so... don't get fully invested in using the X
                     _playerTransform.eulerAngles = desiredRotation; // Set the eulerAngles.
                 }
             }

I added it to the comments, but you may require the Z-axis instead of the X-axis, based on your local rotation of the weapon. Heck, maybe even the Y-axis. Just mess around with it.

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Fps Arm moves fase 2 Answers

FPS (sometimes) invisible gun?! 2 Answers

I want to change gun position with my camera joystick 0 Answers

How to bring reticles in different situations to the center of the camera? 0 Answers

Problem with camera and gun in FPS game 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