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 bercisz · Feb 14, 2013 at 01:08 PM · rifle

Gui texture

Hey, how to make a sniper rifle sight when you press the right mouse button

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 Benproductions1 · Feb 14, 2013 at 10:36 PM 0
Share

Do you know any scripting? Do you know how unity basically works? If so the answer is simple, if not you need to do allot more research before asking this question.

2 Replies

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

Answer by Benproductions1 · Feb 14, 2013 at 10:42 PM

Im assuming you know at least something about unity. You know how to do very basic scripts. You know how to add them to objects and set variables. You have a scope texture.

Here is the simple Answer:

 var Scope:Texture2D; //The Scope Texture
 
 private var ScopedIn:boolean = false;
 
 function Update() {
     if (Input.GetButton("Fire2")) { //Check for left mouse button, set ScopedIn to true else false
         ScopedIn = true;
     }
     else {
         ScopedIn = False;
     }
 }
 
 function OnGUI() {
     if (ScopedIn) { // Check if scoped in
         GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), Scope); //Draw Scope
     }
 }

Hope this helps, Benproductions1

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 gsoft9999 · Feb 14, 2013 at 11:41 PM

when you press a button I would display a textureGUI on the main camera and i would move my camera to a rifle or another way is to make a second camera and call it something like rifle sight , add texture and then switch between the cameras. but creating two cameras i think is easier than moving it. this is the script you need to add it to your scene on any object,this is javascript:

//start

function Update () { if(Input.GetButtonDown("Jump")){ Camera.main.depth=-10; } if(Input.GetButtonUp("Jump")){ Camera.main.depth=10; } }

//end

so if your new to unity then look for your project panel and there should be a button named create click it and then click on javascript. this will create a new java script open it and paste the code above

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

Instantiate bullet in time interval for "rifle". 2 Answers

Sniper Scope With GUI Texture 2 Answers

Mecanim and body orientation 0 Answers

How do I make a look at over time button for Oculus rift and Gear VR? 0 Answers

Scoping For Snipe Rifle 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