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
2
Question by raphu604 · May 07, 2014 at 11:21 PM · camerafpsshadowsdepthclear

Gun and player model clipping through walls. How do I fix WITHOUT using multiple cameras?

Hey guys, I've been struggling with this issue for quite a long time now. I am creating a simple FPS with a full body player model setup. The problem is that my guns and player model clip through geometry sometimes (especially in corners and face-to-wall).

I tried creating a second camera that clears depth only and only draws my player model layer, but then my player model and gun don't cast shadows.

Then I tried creating a "pull gun back" animation that plays whenever a raycast detects colliders in front of the player, but that isn't precise enough either, as the time the animation needs to transition into the pulled back position is enough to see the gun clipping through geometry for like 0.3 seconds at corners (and especially at very tangent angles from walls whilst walking/running).

Can somebody help me fix this? Thanks in advance :)

Comment
Add comment · Show 7
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 meat5000 ♦ · May 07, 2014 at 11:45 PM 1
Share

For realism, don't allow your player to get so close to the wall.

$$anonymous$$ight sound like a crap suggestion; if you are using physics this won't be a problem, I think.

$$anonymous$$ake your colliders and bounds slightly larger.

avatar image meat5000 ♦ · May 08, 2014 at 12:00 AM 1
Share

If you are using $$anonymous$$ecanim, you could consider implementing the Leaning as a BlendShape. On detecting a collision with the wall the lean can be set to go no further than its current lean.

If you use Blender this is called Shape$$anonymous$$eys.

avatar image raphu604 · May 08, 2014 at 12:04 AM 1
Share

Yup, thought of that too :D

But the problem is not much within the leaning per se, but rather the fact that with such "big-ish" colliders and bounds you would never even get so close to a wall to actually need the leaning functionality at all :/

avatar image meat5000 ♦ · May 08, 2014 at 12:21 AM 1
Share

That's a good consideration.

I think the only game I user used a Lean was in $$anonymous$$GS and that was probably just to play with PS2 pressure sensitive buttons :D I end up getting frustrated that games have Lean on PC as I like my E button to be 'Use' :P

Games have handled this differently since the dawn of time (If the dawn of time is when FPS games came out). Some do the back-against-the-wall routine. Camera/Layer trickery in others. If there is no $$anonymous$$ultiplayer involved, so noone observing your Player model in 3rd person you can get away with a pull-back in the form of the weapon disappearing back in to the camera, -Z stylee. Imagine your face up against a wall... the camera moves forward but the gun stays still so you can no longer see it. I guess retract rather than pull back; disappearing under the camera, per se.

avatar image raphu604 · May 08, 2014 at 12:37 AM 1
Share

Yep, I decided to stick with the weapon retract/pull back method :) thanks

PS: high-five for $$anonymous$$GS-love :')

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

FPS Don't draw mesh, do draw shadows, but mesh needs to be drawn on mirror material. 0 Answers

Should I use dual or single camera for fps game? 1 Answer

how can i render an object (like a gun in a fps game) on top of everything (like showing it even if i went into a wall) with recieving shadows on it? 0 Answers

Make a mesh invisible but still cast shadows 1 Answer

Can't get depth shaders to work. 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