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 user-9668 (google) · May 07, 2011 at 09:30 PM · javascriptweaponswitchpickupswitch objects

Weapon pick up and switching script

Can someone tell me how to make a weapon pickup script, to pick up weapons randomly on the map and later be able to switch them. I want to have a maximum of two guns you can switch(like in COD) and then resultly pick a new weapon up and replace with your gun you are holding. The thing is I have tried some many times to do this but I never came to a result. I would prefer C# since I am more familiar with it.

Thanks in advance

Comment
Add comment · Show 3
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 GesterX · May 07, 2011 at 09:47 PM 1
Share

Post your script so far and we'll help you fix it. No one is going to write an entire script for you...

avatar image user-9668 (google) · May 11, 2011 at 09:12 PM 0
Share

I posted my script at "Detecting Input from the start function (C#)" But I got no answers :)

avatar image mocky55 · Jul 22, 2015 at 03:47 PM 0
Share

what happens when you're in range for 2 weapons? How would you solve that?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by NinjaSquirrel · May 07, 2011 at 11:10 PM

For picking up a weapon simply think like this:

  1. if someone touches this weapon
  2. ask the player if he wants to pick it up (GUI)
  3. if they say yes
  4. move the weapon to the player hand

For switching between them try thinking like this:

  1. when the player [link text][1] to switch weapons
  2. instantiate the respective primary or secondary weapon to the player.

No one is going to give you code like that, but what I said is how you should think about doing it.

I hope this helps, good luck!

[1]: http://unity3d.com/support/documentation/ScriptReference/Input.html 4. "pushes a certain button"

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
0

Answer by burgunfaust · May 08, 2011 at 03:18 PM

As far as changing weapons, look at this: http://answers.unity3d.com/questions/53579/turning-the-mesh-renderer-back-on-problem/53723#53723

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

1 Person is following this question.

avatar image

Related Questions

Weapon Switching 1 Answer

Why doesn't this weapon switching script work 1 Answer

best way to weapon swapping 0 Answers

Switching/Picking up items in a third-person game 2 Answers

Cycling through enum with key press 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