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 Michael 16 · May 07, 2011 at 06:05 PM · camerarangeaimingsniper

Bombs and Sniper Camera

I got 2 questions:

1: I made a bomb and when I throw it it should kill all the enemys in range of 50 meter fron the bomb. Can someone explane how to do that because I don't know how? (The bomb needs to have a collision with everything).

2: I want to create a simple sniper. to use the weapon I need to activate the camera on it for aiming with keys because it a third person game and I don't use the mouse. How I press a key, activate the camera on the gun, when the camera works see the sight GUI, rotate the camera with the keybourd keys and able to walk while it works (to go back to the main camera I can do by myself after I will know how to do what I asked)? I don't know how to do it... the sniper don't needs to have a zoom.

Sorry for poor english (as allways..).

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 Brandon 9 · May 07, 2011 at 06:56 PM 0
Share

I'm sure your first problem could be solved using Raycasting but I really am a novice when it comes to scripting so I can't be of much help in actually getting it done for you. But if nothing else, I'm sure thats where you are going to want to start.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tommy · May 07, 2011 at 06:22 PM

if (Input.GetKey ("P"))
{
    GameObject.Find("Camera").GetComponent("Camera").active = false;
    GameObject.Find("Sight").GetComponent("Sight").active = true;
    //Change camera to the sight when you press P
}

Attach the "Sight" camera to the sniper, then simply have a GUI skin attach to the "Sight" camera.

Comment
Add comment · Show 3 · 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 Michael 16 · May 08, 2011 at 04:22 AM 0
Share

But this code attach to what? It don't work

avatar image Tommy · May 08, 2011 at 10:01 AM 0
Share

You can attach it to anything, make a new empty gameObject and attach it. $$anonymous$$ake sure you put it an Update() function, and that you have named you camera for the sight "Sight", and you main camera "Camera".

avatar image Michael 16 · May 08, 2011 at 01:44 PM 0
Share

Now I can go to the sight but I can't see nothing and I get this error: "NullReferenceException: Object reference not set to an instance of an object". And I found error in your script: you put 'P' and not 'p', I changed that.

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

No one has followed this question yet.

Related Questions

Standard asset question 1 Answer

Mouse Aiming + Fixed Camera + Independent Keyboard Movement 3 Answers

Limit cameras near range ? 1 Answer

Using raycast from camera to aim shots 1 Answer

ScreenToWorldPoint exclude objects or layers? 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