- Home /
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..).
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.
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.
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".
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
Follow this Question
Related Questions
Standard asset question 1 Answer
Mouse Aiming + Fixed Camera + Independent Keyboard Movement 3 Answers
Limit cameras near range ? 1 Answer