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 JellyCakes · Mar 06, 2011 at 08:04 PM · animationfpsweaponclipping

First Person Weapons clip with terrain geometry

Hello

Currently in a first person game I am developing in C# I find that if I aim towards an object or part of some terrain that the weapon clips through it.

I am not to wise with scripting so I would be very thankful of a possible fix.

At the moment for fixes I have thought about making the weapon on another layer to stop clipping, or to play an animation of the weapon drawing more towards the player when an object is within close proximity.

Sadly I do not know how to go about either solution so if I could be shown how to approach both methods that I have suggested or any other methods to avoid clipping then I would appreciate it.

Thanks.

PS: Just to reiterate I am developing the game in C#.

Comment
Add comment · Show 1
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 Eric5h5 · Mar 06, 2011 at 09:03 PM 0
Share

Already asked/answered: http://answers.unity3d.com/questions/10620/always-render-a-object-on-top-of-another

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by maxwelldoggums · Aug 28, 2012 at 10:25 AM

I've just figured this out recently! :D What you need to do, is draw the weapon separately, and overlay it onto the main game camera.

Put your weapon model in a new layer using the inspector, then create a new camera. Specify your main camera to not render the weapon layer. You can do this using the "culling mask" field of the camera in the inspector. Next, set the new camera to ONLY render the weapon model. Then, set the new camera's "Depth" to 1, putting the weapon camera drawing viewport "in front" of the main camera. Finally, set the weapon camera's "Clear Flag" to don't clear, making the background transparent for this viewport. This should draw the weapon on top of the rest of the scene, and with no scripting whatsoever, you can draw your weapons on top of the scene.

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
avatar image
0

Answer by WoodStick · Oct 23, 2016 at 04:52 PM

This unfortunately didn't help me with the issue. It worked after following your steps and setting the cameras projection to "orthographic" (with a size of approx .5).

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 Cherno · Oct 23, 2016 at 06:14 PM 0
Share

I suggest making the gun and arms very small, small enough that they will fit inside the character's collider. If you set the position correctly, there will be no difference and this solution has no issues with lighting etc.

Of course, it requires you to use seperate GameObjects for viewport and world models. However, thisi s actually what pretty much all modern FPS games do, where the viewport model is typically much more detailed than the world model, and sometimes also stretched along the z axis for a nicer appearance from the player's view.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

FPS Weapon and animation 1 Answer

Select Object ( Weapon ) Quick! Help! xD 1 Answer

FPS animations for different purposes? 1 Answer

Switch Weapon Script Not taking effect HELP!! 2 Answers

Multiple Weapon Animation Help 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