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-2679 (yahoo) · May 21, 2010 at 08:32 PM · grenade

Why doesn't my grenade go anywere

My grenade when i hit 2 and select it and click to throw it u see the clone come and blows up right in front of u. Basically the object doesn't go a distance.

I fixed it but now if i have my machine gun out it shoots both my machine gun and grenade

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by IronWarrior · May 21, 2010 at 10:03 PM

How is the grenade detonated? It depends on what method you're using to blow it up...does it explode after a certain amount of time or due to a collision?

If it's due to a collision, it might be colliding with the character controller that's launching the grenade. To avoid this, you can use Physics.IgnoreCollision between the grenade and the player.

http://unity3d.com/support/documentation/ScriptReference/Physics.IgnoreCollision.html

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
1

Answer by Jason_DB · May 22, 2010 at 01:34 PM

Well if its firing both of your weapons at once that means that both weapon scripts are active. Make sure that you have a boolean for each weapon which turns it off (stops it from firing or doing anything) and then only have the weapon you selected be on.

Like DarkHype said the FPS tutorial will explain all of this and includes some neat prebuilt stuff so it's worth checking out especially if you're new to unity (it is a nice introduction to scripting in addition to teaching about FPS's).

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 DarkHype · May 22, 2010 at 08:28 AM

You can use FPS tutorial for your problem it explains weapon switching firing rockets and bullet so if i were you i would use that tutorial!

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 Kashaunzilla · Apr 28, 2011 at 11:58 PM

Well change from Fire1 button to like Input.GetKeyDown("f") Well here something i put together for throwing your grenade. Just attach to your player.

var grenadePrefab : Transform;

function Update () { if (Input.GetKeyDown("f")) { var grenade = Instantiate(grenadePrefab gameObject.Find("grenadeSpawner").transform.position, Quaternion.identity);

     grenade.rigidbody.addforce(forward * 500);
 }

}

Ok what you know what you need to is place a empt gameobject where you want your grenade to be thrown from. Place it as a child of the of the maing camera if a fps game and player if it is a 3rd person game. change the 500 to however you want the throwing speed to be, and set the grenade as your grenadePrefab spot. And hit the f key to throw the grenade, when the grenade is spawned it will explode from your own script. That will make your grenade move from the spot. I am pretty sure your have your own grenade exploding script.

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

No one has followed this question yet.

Related Questions

multiple raycasts in sphere shape (grenade explosion) 1 Answer

Scripting a grenade 2 Answers

GrenadeScript.cs Troubles 1 Answer

Grenade Script 1 Answer

How to rotate a object against another 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