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
1
Question by hugemaggot · Dec 05, 2010 at 04:54 PM · fpsweaponpickup

picking up guns

ive been working on a horror fps game in unity for a while now but i dont know how to pick guns up my game starts off when you are being tortured, but you then somehow kill everyone and escape the room you then find a gun which "you pick up" and escape the building.

so can anyone tell me how i would do this?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by JesusChristChangedMe · Dec 05, 2010 at 08:39 PM

there is a way to do this. you will have to use a parenting technique. makeing the gun a child of the player. this will take work but here is how to do it. First you will have to make a sphere. gameObject-> create other-> sphere. after you have one put it exacly where you want the center of your gun to be spawned at. then drag it in your hierarchy onto your player. thus making it a child of the player. then uncheck the mesh renderer on the sphere and remove the collider component. make sure the player is tagged "Player". make sure that in the script below that the sphere you created goes in the SpawnTo place and that your gun goes in the Gun place. there should be a place to drag it onto after you have attached this script to your gun it should give you

  • SpawnTo-(Transform)
  • Gun-(Transform)

now make this script.

var SpawnTo:Transform;
var Gun : Transform;
function OnCollisionEnter(hit:Collider)
{
if(hit.gameObject.tag == "Player")
{
Gun.parent = SpawnTo;
Gun.transform.position = SpawnTo.transform.position;
Gun.transform.rotation = SpawnTo.transform.rotation;
}
}

Hope this Helps!

Comment
Add comment · Show 6 · 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 hugemaggot · Dec 05, 2010 at 08:54 PM 0
Share

when i copy the script which you have given me an error comes up in saying "parent is not a member of unityengine.gameobject"

what does this mean and how can i fix it?

avatar image Jesus_Freak · Dec 05, 2010 at 11:19 PM 0
Share

another error that might come up is about the transform.rotaion, just make that word rotation.

avatar image Jesus_Freak · Dec 05, 2010 at 11:21 PM 0
Share

a syntatical way to fix this is chnage the declaration of GameObject in the vars to a Transform. ie: var SpawnTo : Transform;

avatar image JesusChristChangedMe · Dec 06, 2010 at 01:56 AM 0
Share

well i kinda looked at some of my other scripts and edited this one... let me make sure about that parent error. but try this and see what happens.

avatar image JesusChristChangedMe · Dec 09, 2010 at 09:08 PM 0
Share

Ok this should work now

Show more comments

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

picking up weapons script? 3 Answers

Weapon pick up 3 Answers

Weapon Prefab 0 Answers

Avart Fate with Gun Movement 0 Answers

Problem With Weapon Firing Mechanism 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