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 /
This question was closed Jul 27, 2013 at 06:35 PM by AlucardJay for the following reason:

Too subjective and argumentative

avatar image
-2
Question by Josh1231 · Jul 26, 2013 at 07:42 PM · c#collisionfpsgun

C# How to have weapon pickup

I wanted to ask how i can have weapon pick up when i go over the weapon, whenever i try he does go over the weapon but when i press the equip button nothing happens

Comment
Add comment · Show 15
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 gregzo · Jul 26, 2013 at 07:52 PM 2
Share
  • because you have way too many reputation points to be asking such a question.

avatar image clunk47 · Jul 26, 2013 at 07:55 PM 3
Share

@gregzo Dude you can't give a thumbs down based on someone's karma points. He only has 190 anyway. Why waste 2 of your own karma points to vote someone down for a ridiculous reason. I have over 6,000 and I still am learning, just like most people here. If you don't have something constructive or you're not asking for more information on the topic because you're willing to help, don't even comment.

avatar image AlucardJay · Jul 27, 2013 at 11:52 AM 2
Share

I'm trying to renew my reputation here on UA, but I kinda agree with @gregzo on this one (in principle, not the reason for action). As clunk47 first rightly pointed out, the question is vague and uninformative. This is the type of question I used to immediately close. $$anonymous$$y generic post is :

Sorry, but your question is not suitable for Unity Answers. Please use the Unity Forum for discussions such as "How to ...". Unity Answers is here to help you solve any specific problems you have.

If you submit your code when asking a question, we can see what you are trying to do and help from there.

  • http://forum.unity3d.com/

  • http://answers.unity3d.com/page/newuser.html

  • http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

But as one user told me recently, no-one here likes me, so please ignore this comment, I'm really not an a***hole (really!)

@Josh1231 , please consider editing your question with a better description of your problem and what you're trying to achieve, and include the code you have posted as a comment.

avatar image AlucardJay · Jul 27, 2013 at 03:42 PM 1
Share

You are correct, I was very vague in explaining my reasons for assessing it as such. I feel my credibility slipping further away....

You have a good point clunk47, made me think hard about giving reasons. Honestly, result should be directly proportional to effort applied;

avatar image Lo0NuhtiK · Jul 27, 2013 at 06:20 PM 1
Share

@gregzo didn't downvote for its karma alone. It was downvoted because, based on its karma, it should have known better than to ask such a vague question.

...and I think everyone on here has the right to up or down vote anyone else for any reason or no reason at all; it's entirely up to them.

I'll give it a down vote also. Reason : I'm bored.

Show more comments

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Kawaburd · Jul 26, 2013 at 08:10 PM

Normally you'd want to destroy the weapon instance when your PC (or cursor, or whatever you're using) collides with the weapon, then stick a variable representing the weapon data... well, wherever you need it. It depends on so many things (one possible weapon, or many? FPS? RPG? something else?) that without giving more information (or trying it yourself and posting a code snippet), that's about as specific of an answer as you're going to get.

Comment
Add comment · Show 10 · 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 Josh1231 · Jul 27, 2013 at 10:34 AM 0
Share

this is what i put, is it correct?:

 void OnTriggerEnter(Collider collision) {
     if (collision.gameObject.tag == "Gun")
        {
        print ("Gun Found");
        if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.E))
          {
          GunStay gunstay = collision.gameObject.GetComponent<GunStay>();
          gunstay.EquipGun(this.gameObject);
          }
        }
 }

there is also this for having the gun in the hands but i don't know how to make it work because i can't do foreach (Transform child in currentHolder):

 public void EquipGun (GameObject holder) {
     if (equip == false)
        {
        equip = true;
        currentHolder = holder;
        }
     else
        {
        equip = false;
        currentHolder = null;
        }
     }

 
 // Update is called once per frame
 void Update () {
 if (equip == true)
    {
    GameObject GunStay = GameObject.FindGameObjectWithTag("GunStay");
    if (GunStay.networkView.is$$anonymous$$ine)
      {
      Vector3 GunGo = GunStay.transform.position;
      Vector3 temp = transform.position;
      temp.x = GunGo.x;
      temp.y = GunGo.y;
      temp.z = GunGo.z;
      transform.position = temp;
      }
    }
 }
avatar image Josh1231 · Jul 27, 2013 at 10:35 AM 0
Share

it doesn't work properly

avatar image Chronos-L · Jul 27, 2013 at 11:59 AM 1
Share

I don't think Input.Get$$anonymous$$eyDown will work in OnTriggerEnter. This restructured version of your script might work.

 private GunStay gunstay;
 
 void OnTriggerEnter(Collider other) {
     if (other.gameObject.tag == "Gun")
     {
         gunstay = collision.gameObject.GetComponent<GunStay>();
     }
 } 
 
 void OnTriggerExit(Collider other) {
     if(other.gameObject == gunstay.gameObject ) {
         gunstay = null;
     }
 }
 
 void Update() {
     if( gunstay!= null && Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.E) ) {
         //Equip your gun here
         ...
         gunstay == null;
     }
 }
avatar image Josh1231 · Jul 27, 2013 at 12:06 PM 0
Share

i got an error code: `gunstay' conflicts with a declaration in a child block

avatar image AlucardJay · Jul 27, 2013 at 02:41 PM 4
Share

ok, now you get downvote from me, for not following advice and and editing the question, and not effectively expressing your setup.

Show more comments

Follow this Question

Answers Answers and Comments

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

Related Questions

How to check if an object is colliding with another from another script ? 1 Answer

Allow picked up object to collide with game level GameObjects 1 Answer

First Person Controller 1 Answer

C# Collision Detection Help 0 Answers

Collision Detection not Firing 0 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