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 bladelock · May 02, 2012 at 04:44 PM · camerafpszoomsniper

How to add sniper zoom effect in an FPS made with Unity3d?

Hello!

I've been following parts of the FPS tutorial in the Unity website, while creating my own code based on the ideas and concepts illustrated by parts of the code in the tutorial.

I've been wondering how to add some sort of sniper zoom effect for my FPS (for example, a sniper rifle)

I've been struggling trying to follow the flow and ideas being shown by the tutorials I have seen regarding the snipe scope so far.

I've been having some idea of how the zoom may work, primarily such as

  • zooming the "Main Camera" of the game by shifting the camera's position a certain distance away from the FPS Controller Game Object

This is the approach that i could think of. Would this be a feasible approach? Also, if it is, what kind of functions would I have to know in Unity to be able to execute the effect?

And if there is understandable code, is there "good" code written in C#

Or if there's a "beginner-friendly" tutorial on it, can you show me the way?

Cheers.

PS: I will highly appreciate if someone could type some sample code about the sniper zoom effect here. Cheers again!

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

2 Replies

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

Answer by apocriva · May 02, 2012 at 05:52 PM

You'll want to adjust the camera's field of view to be smaller to simulate looking through some kind of scope.

http://unity3d.com/support/documentation/ScriptReference/Camera-fieldOfView

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
1

Answer by cyble · May 02, 2012 at 07:35 PM

Just lower your camera.fieldOfView and that's it ! Animate that value using a tween to get that animating zoom effect, and you're all set.

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

Sniper Demo: When zoom the raycast change its aim ! 0 Answers

Sniper zoom when right click? 1 Answer

Scoping script /Camera zoom preferably C# 3 Answers

Sniper Scope? 1 Answer

Sniper scope zoom if crosshair is not in the middle of the screen 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