Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
xMGIsBae

Weapon Clipping

Question

I'm pretty new when it comes to scripting so I was wondering if anyone could guide towards doing this or even show me a script on the the asset store that'd be nice. I would like where when the player comes up to a wall the weapon moves up and away, something like battlefield or even pubg. Any help would be nice :YMPEACE:

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 1

Add a camera, set it's render priority to 1 and create a layer called weapon. Then make that camera only render the weapon layer and set its culling to depth. That makes it so it doesn't clip walls (on your camera). Next, you can either raycast or use a trigger cube. If the raycast or trigger cube hits something (that's not the players collider), then make the arms rotate towards transform.up, else, rotate towards transform.forward

 

edit: scratch that. Just crossfade an animation instead of screwing with coding, it'll be a lot easier for you to make it look good. But you still wanna do the camera thing

Share this post


Link to post
Share on other sites

  • 0

Yeah I already know the first part but the second part is what I needed help on, Is there any tutorial for the second part?

Share this post


Link to post
Share on other sites
  • 0

There's really no tutorial needed, it's very basic stuff. The basic idea is:

 

if(Physics.Raycast(transform.forward,hit, 1))

{

animation.CrossFade("LiftGun");

}

else animation.CrossFade("LowerGun");

 

that's pretty much it. 

 

Please login or register to see this link.

Please login or register to see this link.

 

as a beginner, just scroll the docs and take notes. Everything is there

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...