• 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 Commander Quackers · Dec 12, 2013 at 12:11 AM · camerainstantiatefpsbulletgun

Which is better, shooting a bullet from camera or from the gun itself?

Hi,

I was wondering if it would be a better idea to instantiate a bullet projectile from the camera in the forward direction of the player, directly to the dynamic crosshair, or if it would be better to instantiate it from the gun itself. I prefer to launch it from the camera but, will t$$anonymous$$s give me any problems/difficulties in the long run, like later on? Thanks

[Edit] I also have a muzzle flash/firing animation so it does look convincing. The bullet cant be seen either (bullets don't get seen anyways.)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by guitarxe · Dec 12, 2013 at 12:16 AM

It's really up to you, but if you do it from the camera and the camera's position is on the eye-level of the player model, then you will get t$$anonymous$$ngs like the player model being crouched be$$anonymous$$nd a car or somet$$anonymous$$ng, with the gun being obstructed by the car, but the player still being able to shoot over it because the bullets are actually coming out from the eyes.

It's weird as heck, but t$$anonymous$$s is how most FPS games do it anyway. See any of the COD games for example.

Comment
Add comment · Show 2 · 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 Commander Quackers · Dec 12, 2013 at 12:21 AM 0
Share

Thanks, makes sense. They come from the GunCamera, which is just a child camera of the main camera (both positioned the same.) So the bullet is pretty much coming straight from eye level to the center of the screen, but I highly doubt the player would ever figure this out because the bullets can't be seen. One thing that does worry me though, is if the player was close to a wall, like right near it, and fired a bullet, the bullet hole would go right to the center, not where the gun is pointing. Anyways, thanks for the answer, I'll mark as accepted.

avatar image guitarxe · Dec 12, 2013 at 02:35 AM 1
Share

CoD and other modern FPS games mask this by, obviously, showing a muzzle flash on the gun when being fired, which of course gives a strong believable expectation that the bullet comes from the gun, but also for drawing the tracer bullets, these are also seen as coming from the gun's position, not from the camera's position. Combined, there really isn't any reason for the player to think the bullets don't actually come from the gun itself.

The times when this illusion is broken and the player can see what's going on, like the example I provided or the one you mentioned with the wall, they don't really cause much of a problem for a player's enjoyment of the game. At least, I've never heard of people creating a big fuss about it. It's just a "heh, that's funny, so that's how they do it" moment for most gamers, probably.

And in fact, with your wall example, that's not as big a problem as you think. The bullet hole decals are drawn where the crosshair is pointing to. That's where the player expects the bullets to be. Especially since even though the player is right up to a wall, the 1st person model of the gun still points forward, where in real life this would have to be lowered in order to press closer to the wall. This gives the player an illusion of distance between them and the wall.

avatar image
0

Answer by EX_Darius · Dec 12, 2013 at 12:16 AM

It should not give you any problems in the long run, however I do strongly suggest you properly shoot from the gun as t$$anonymous$$s will be alot easier to work with (for example if you want to create a 3rd person view or somet$$anonymous$$ng simular)

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 Commander Quackers · Dec 12, 2013 at 12:25 AM 0
Share

I'm not sure whether or not I will add 3rd person view, but the bullets can't be seen. Thanks

avatar image
0

Answer by Kiloblargh · Dec 12, 2013 at 12:18 AM

It's a bad idea to instantiate projectiles for bullets, period. You definitely want to use a ray cast.

For a slower projectile, like a rocket, you should instantiate it from the gun. If you instantiate it from the camera, all you will see is its back end getting smaller and smaller until it $$anonymous$$ts the target. And other players (if any) will see it coming out of your face instead of the gun. I can't see any reason why you would want to fire it from the camera's position when it's just as easy and more accurate to fire it from the gun.

Comment
Add comment · Show 4 · 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 Commander Quackers · Dec 12, 2013 at 12:24 AM 0
Share

What are the downsides to using projectiles for bullets? They don't have a mesh, and they get destroyed after a certain time has passed. The bullets travel far too fast to be seen (only if the timeScale was like .001, and I'm not planning on adding Slow Motion to the game.) I'm not very experienced with RayCasts either, but I will look into them, thanks for the reply!

avatar image EX_Darius · Dec 12, 2013 at 12:28 AM 0
Share

problem with instatiating bullets is that it takes up a lot of unneeded processing power, would be even worse if the bullets had rigidbodies. Not everyone has a very good computer, im not even gonna start about mobile devices.

avatar image Kiloblargh · Dec 12, 2013 at 12:29 AM 0
Share

The fact that they travel far too fast to be seen is the reason why it's a bad idea to do it that way. You put unnecessary strain on the physics engine having all those colliders flying around when an instantaneous ray cast would suffice; and can run into problems of bullets passing through walls because they are on one side of a thin box collider one fixedupdate, and on the other side the next, and so never actually colliding.

avatar image Commander Quackers · Dec 12, 2013 at 12:36 AM 0
Share

My bullet projectiles are rigidbody spheres (just for now until I figure something else out) that have a script that ensures they collide, regardless of the frames. Raycasting does seem like a better idea though, I will look into it now.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

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

Transform.position bullet won't align 1 Answer

How to instantiate a prefab in front of FPS camera? 3 Answers

Problem with camera and gun in FPS game 0 Answers

FPS MultiPlayer 2 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