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 nichos1 · May 11, 2013 at 12:43 AM · fpssimplemagic

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

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 Ajaxx84 · May 11, 2013 at 02:07 AM 0
Share

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?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

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 nichos1 · May 11, 2013 at 03:00 AM 0
Share

when you mean code to shoot, how would I do that?

avatar image Ajaxx84 · May 13, 2013 at 02:55 AM 1
Share

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.

avatar image AlucardJay · May 13, 2013 at 03:15 AM 0
Share

@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

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

16 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 avatar image avatar image avatar image avatar image avatar image

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


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