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 recondev · Oct 06, 2012 at 02:02 PM · javascriptfpszoomaimscope

gun scope cam not working

I am starting a fps game. I am currently doing the scope part of a m4a1.

I made a cam for the scope called scopecam and a javascript called scope.

here is what it is inside the script:

     var Aim : boolean = false;
     
     var Cam : GameObject;
 
 function Update () {
 
 
         if (Input.GetMouseButtonDown(1)) {
 
             Aim = true;
         
             if (Aim == true) {
         
                 Cam.active = true;
         
         
         
             }
         
         if (Input.GetMouseButtonUp(1)) {
     
             Aim = true;
     
             if (Aim) {
     
                 Cam.active = false;
                 
             }
     
         }
     }
 }

I believe that 1 is for the right mouse, isnt it?

after that i have linked the script to the first person controller and the cam to the fp controller too.

I have also dragged the cam to the script where it says - cam: none(gameobject).

everything is ok until when i test the game, the scope is not responding.

thanks for the help!

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

Answer by chrisall76 · Oct 06, 2012 at 02:16 PM

Make sure that your also disabling the main camera when you scope, here's what I did:

 var ScopeToggle : boolean = false;
 var ScopeCam    : Camera;
 var GunCam      : Camera;    //I have a separate camera that renders my guns,
                              //You can set this to the main camera if you want
 
     if (Input.GetButton("Fire2")){ //Fire2 is the same as rightmouse
         ScopeToggle = true;
         
     }
     
     if (Input.GetButtonUp("Fire2")){
         ScopeToggle = false;
     }
     
     if (ScopeToggle){
         ScopeCam.gameObject.active = true;
         GunCam.gameObject.active = false;
     }
     
     if (!ScopeToggle){
         ScopeCam.gameObject.active = false;
         GunCam.gameObject.active = true;
     }
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
0

Answer by recondev · Oct 06, 2012 at 02:48 PM

it is still not working though? i've changed the main camera to GunCam, and changed my script to yours and nothing happened when i chick and hold the right mouse.

but thanks for the help

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 chrisall76 · Oct 06, 2012 at 03:51 PM 0
Share

You've also added the scope cam to the scopecamera variable right?

avatar image recondev · Oct 06, 2012 at 07:04 PM 0
Share

like this?

var ScopeToggle : boolean = false; var ScopeCam : ScopeCamera; var GunCam : Camera; //I have a separate camera that renders my guns, //You can set this to the main camera if you want

 if (Input.GetButton("Fire2")){ //Fire2 is the same as rightmouse
     ScopeToggle = true;

 }

 if (Input.GetButtonUp("Fire2")){
     ScopeToggle = false;
 }

 if (ScopeToggle){
     ScopeCam.active = true;
     GunCam.active = false;
 }    

 if (!ScopeToggle){
     ScopeCam.active = false;
     GunCam.active = true;
 }
avatar image chrisall76 · Oct 07, 2012 at 03:59 PM 0
Share

That may wor, try testing out things until it works.

avatar image recondev · Oct 08, 2012 at 08:45 PM 0
Share

it is still not working

avatar image
0

Answer by BasicGames · Nov 24, 2012 at 08:29 PM

By me the same, it aims the whole time if I select "scope toggle" if I deselect it there happens nothing :(

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

11 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

Related Questions

How to change the sensitivity on right click (when zoomed in) 2 Answers

FPS Aim Down Sights. Exact Position. 1 Answer

How To Set Scope Speed 2 Answers

Modern Warfare Styled Zoom? (Javascript issue) 0 Answers

An instance of type (Script) is required to access non static member (Script) 1 Answer


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