- Home /
Straight shooting when mouse pressed(not held)
Hi, i'm fairly new to the unity community(just switched from game maker) and I'm trying to make a fps, but not with guns. I have the first person view down and all I want to do is whenever I click it creates a cube that moves to the mouse and I want the cube to get destroyed when it collides with a wall etc. Thank you so much
What do you have so far? Can you post what code you have? Or are you looking for someone to write all the code for you?
Answer by LPGaming · May 11, 2013 at 02:57 AM
if(Input.getKeyDown(KeyCode.L)) {
//Code to shoot
}
This will shoot once the key "L" is pressed, but will only fire once if you hold it down, this function can be used for a mouse aswell, KeyCode.MouseButton0 i believe is left mouse.
It has become quite apparent you have absolutely no knowledge in the area of coding. So I am going to assume the answer to me question is that you are looking for someone to write the code for you..
there is a lot more involved than simply writing out a small section of code and having it all work, what are you shooting? is it a physical object? if so than you need to make that object, import it into your game, turn it into a prefab, than have the code instantiate it. is it not a physical object? than you could probably use a raycast. Is it a laser? than you would probably want to use a particle effect combined with a raycast. Is it a 2d side-scroller? than you would need to make the graphic image for whatever it is you want being shot and instantiate that.
Simply put. You need to provide as much information as possible, what exactly are you trying to achieve, do you have any code already, do you know anything about coding, do you have a physical object to instantiate, or can make one?
$$anonymous$$ore detail = better.
I would highly suggest you go through the modules here : http://www.unity3dstudent.com/category/modules/ and by the time you are done you should have the basic knowledge for doing what you are trying to do.
@LPGa$$anonymous$$g : check your spelling and capitols .... Get$$anonymous$$eyDown =]
to the OP (nichos1) :
http://docs.unity3d.com/Documentation/ScriptReference/Input.Get$$anonymous$$eyDown.html
http://docs.unity3d.com/Documentation/ScriptReference/Input.Get$$anonymous$$ey.html
http://docs.unity3d.com/Documentation/ScriptReference/Input.html
I absolutely agree with @Ajaxx84, nichos1 start by watching the Unity 3D Student series.
Your answer
Follow this Question
Related Questions
Choppy on iPhone only... 1 Answer
Simple crosshair script 1 Answer
Simple scene makes LOW FPS between in 3.9... 0 Answers
First Person Shooter Help With Cam 1 Answer
How Would I Make The Game Go To Next Level After i Hit 1000 Points? 3 Answers