Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 fsdjfsdkjfsdk · Jul 28, 2015 at 10:27 PM · lerpgunscope

How would you implement ADS for Custom Scopes?

Just a basic question here:

I have a game that has guns that can be found in the world, each gun can have a different scope. Example: A player can find a pistol, and put a RDS scope on it through the attachments menu.

Each gun has an empty gameobject called "ScopePivot" and this is where the scope is placed when the player selects it in the attatchments menu. When the scope is placed in attachments menu, its parent is set to the "ScopePivot" object, and its local transform is reset as well. This way any scope can be easily attached to any gun.

I was trying to find a way to implement Aim Down Sights. I have settled on lerping the scope to right in front of the cameras position, however because the scope is child on the gun, only the scope will move if I use this technique. This will leave a floating scope in front of the camera, and a gun still by your side in the idle animation.

Any suggestions on a good way to implement Aim Down Sights with my setup. Keep in mind that each scope will be a different height, width, ect...

I don't need the code written for me as I'm fairly experienced in C#, but if anyone has a basic idea of how they would, or have, implemented this, it would be much appreciated.

Please comment if you think me explanation is hard to understand, as I can reword it or add pictures.

THANKS

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 Positive7 · Jul 28, 2015 at 10:49 PM 0
Share

How about a second camera and align that to the scope centre?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eno-Khaon · Jul 29, 2015 at 12:55 AM

When you attach the scope to the gun, you're effectively defining a local position relative to the gun.

It looks like what you need to do is figure out where the scope will need to be positioned relative to the player, then move the gun with the offset of the scope's position to where the scope would go.

So, if you have the scope working correctly, you should have most everything done already. You'd already know where the scope is at relative to the gun and where the scope needs to be relative to the character/camera. Therefore, in order to put the gun into the correct position, you'd want to determine where the scope needs to move to, but move the gun instead to that position minus the offset of the scope from the gun.

 // Hardly a good example, but just showing what I'm getting at.
 
 public Vector3 scopeToCameraOffset; // Position of scope relative to camera
 Vector3 scopeDestination = Camera.main.transform.position + scopeToCameraOffset;
 
 Vector3 scopeToGunOffset = scope.transform.position - gun.transform.position;
 
 Vector3 gunDestination = scopeDestination - scopeToGunOffset;
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

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

Related Questions

Aiming down gun scope 1 Answer

How to bring reticles in different situations to the center of the camera? 0 Answers

Changing camera position to shoot through scope on gun 1 Answer

Gun Scope Not Centered 1 Answer

How To Make A Gun Scope Zoom In 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