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 LFZ2 · Nov 17, 2010 at 02:51 PM · prefabbulletclickshoot

My object acts wierd, 2 balls being shot instead of one (from different position)

the ball should be shot from one position, not two here is the code:

public var snowballPrefab : Transform; public var snowballSpeed : float = 6000;

function Update(){ if(Input.GetButton("Fire1")) { if(!snowballPrefab || !snowballSpeed) { Debug.Log("[Shoot] 'bulletPrefab' or 'bulletSpeed' is undefined"); }else{ var snowballCreate = Instantiate(snowballPrefab, GameObject.Find("SSpawnPoint").transform.position, Quaternion.identity); snowballCreate.rigidbody.AddForce(transform.forward * snowballSpeed); } } }

It's acting very wierd. I use a Object as Spawn Point, One prefab as bullet, and everything is set up properly, but there are 2 bullets from two points shot instead of from a point.

Comment
Add comment · Show 4
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 Proclyon · Nov 17, 2010 at 02:57 PM 1
Share

Here's my own question for you. Can you check in the editor if you actually see two objects with (clone) behind them come up if you shoot once? And is it possible you really just have one object but the components aren't in the same place making it look in the scene view (not game view) as if there are two? If not I will gladly dig through the code sample you provided

avatar image LFZ2 · Nov 18, 2010 at 11:59 AM 0
Share

Surely I will recheck for you. Thank you for your help

avatar image LFZ2 · Nov 18, 2010 at 12:03 PM 0
Share

I replaced the prefab, rebuilt it, still the same behaviour, and there is something even more strange There are 2 bullets (snowballs) created one from the point specified and one under the mesh (character - player)

avatar image LFZ2 · Nov 18, 2010 at 12:12 PM 0
Share

Sorry for the late response, haven't been yesterday at my workspace.

2 Replies

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

Answer by Mike 3 · Nov 17, 2010 at 04:36 PM

Use GetButtonDown instead of GetButton, the latter returns true every frame that the button is held down

Comment
Add comment · Show 1 · 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 LFZ2 · Nov 18, 2010 at 12:05 PM 0
Share

I am using it already:)

avatar image
0

Answer by LFZ2 · Nov 18, 2010 at 12:06 PM

EDIT 2: Now it's creating one instance of the object:) Point achieved. Is there any way I can make my "spawn point" unmovable? it seems to move down as I shoot.

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

How to shoot a bullet to curser position? 2 Answers

Bullet not always shooting in forward direction. Code included. 2 Answers

Get animation work 1 Answer

Shooting multiple grenades with joystick 0 Answers

Converting button to mouse click 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