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 Jake5150 · Feb 14, 2012 at 07:06 AM · animationfpsweaponclip

FPS Weapon and animation

Hello there, I've begun on creating a FPS game, and I have a few questions. I currently have a weapon model + arms attached to my main camera on my character controller. I was wondering if there is a way to give it an idle animation, like if you just sitting around, the gun and hands and arms move slowly up and down. Also, I have tried to make it so the weapon does not clip though other stuff such as walls. I tried adding a mesh collider, but it only makes it so I cannot jump and can't want when looking down or straight. I know in many FPS game if you hold up your gun to person's head, your weapon appears tiny and does not go though walls and other stuff. Is the viewmodel actually tiny? My weapon is actually equal to the size of a player's head, but looks fine looking around normally. What is an appropriate way to fix this problem?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HamCoder404 · Aug 13, 2013 at 04:20 PM

Part I:

Create an animations script. I have a default code here, remember to create your animations:

 function Update() {
 if(Input.GetAxis("Vertical")){
 // If you go forward or backward...
     if(Input.GetKeyDown(KeyCode.LeftShift)){
         // If you put down left shift...
         animation.CrossFade("Run", 0.1);
                 // Crossfade the animation "Run"...
 
     }
     else
         // If you are not holding left shift...
     {
         animation.CrossFade("Walk", 0.1);
                 // Crossfade the animation "Walk"
     }
 }
 else
 // If your not pressing anything
 {
     animation.CrossFade("Idle", 0.1);
         // Crosssfade the animation Idle...
 }
 }

Crossfade means to merge the animations so they have a smooth flow...

Part II:

I have done this before. Basically, what you need to do is duplicate the camera you are using, and rename it "Gun Cam". On the toolbar click Edit>Project Settings>NavMeshSettings and then add a layer called "Gun". Select your gun and hands and and set the layer to "Gun". Now go click on your main camera and under "Culling Mask" unselect "Gun", and on your Gun Cam Select Only "Guns". Make sure Main camera has a near of 0.2, while you Gun Cam has a near of 0.1! Try it out.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Switch Weapon Script Not taking effect HELP!! 2 Answers

Hot to use walking animation while aiming! 0 Answers

Multiple Weapon Animation Help 0 Answers

problem with weapon animation -.- 0 Answers

Weapon Switch Animations 1 Answer


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