Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 20, 2016 at 06:42 PM by matthrewp.
avatar image
0
Question by matthrewp · Jul 18, 2016 at 01:10 PM · scripting problemphysicsbulletbullets

Bullet Not Working

When I press the space bar, a bullet is supposed to spawn and start flying off. But instead, a bullet spawns and then stays put. This problem is only true for the player though, and not other objects I have spawning bullets. Their bullets spawn and fly off like they're supposed to. The bullets have a constant relative force of 100 z, a drag of 10, and an angular drag of 0.05. Here is my script that spawns the bullets:

 using UnityEngine;
 using System.Collections;

 public class BulletController : MonoBehaviour {

     public GameObject BulletSpawn;
     public GameObject Bullet;
     void Update()
     {
         if (Input.GetKeyDown("space") == true)
         {
             Instantiate(Bullet, BulletSpawn.transform.position, BulletSpawn.transform.rotation);
         }
     }
 }

Here is a picture of my original bullet's components:
https://drive.google.com/open?id=0B_HzgsC9lP3nNlAyS0tweGRtckE

And here is a picture of the clone's components:
https://drive.google.com/open?id=0B_HzgsC9lP3ncnBTT2NRTk1mR2s
(I don't know how to insert images)

What is wrong with my bullets?

Comment
Add comment · Show 2
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 Cherno · Jul 18, 2016 at 01:17 PM 0
Share

Perhaps it collides with the player?

avatar image matthrewp Cherno · Jul 18, 2016 at 01:32 PM 0
Share

If the bullets collide with the player, they are destroyed.

3 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by alexander11 · Jul 19, 2016 at 01:25 AM

Use Rigidbody.Addforce or Rigidbody.velocity that usually works.

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 MrRightclick · Jul 18, 2016 at 01:15 PM

Do you have a script on the bullets that gives them the force? It's kind of hard to say without seeing other than your spawning script, which looks fine. If you do have a script giving the bullets force, check the inspector that any public values are correct.

Also just a guess, but your bullets might collide with the player hitbox and stopping instantly because of that. Try disabling the hitboxes on bullets and test it out. If this is the case, you can then disable collision detection between two objects using https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html or just simply by moving the bullet spawning point outside the player collider.

Comment
Add comment · Show 7 · 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 matthrewp · Jul 18, 2016 at 01:32 PM 0
Share

Sadly, :( this won't solve my problem. $$anonymous$$y spawn point for the bullets is not touching the player, and the only force given to the bullets is because of their constant force component. Thanks for responding!

avatar image ScaniX matthrewp · Jul 18, 2016 at 04:20 PM 0
Share

If you pause the game in the editor, does that bullet have the correct constant force instance assigned and does not have is$$anonymous$$inematic set?

avatar image matthrewp ScaniX · Jul 18, 2016 at 08:54 PM 0
Share

Yes and yes.

Show more comments
avatar image BloodBTF matthrewp · Jul 18, 2016 at 04:39 PM 0
Share

Does the rigidbody on the bullet have is$$anonymous$$inematic set to true?

avatar image matthrewp BloodBTF · Jul 18, 2016 at 09:03 PM 0
Share

No and the image has been posted.

Show more comments
avatar image
0

Answer by KnightNobody · Jul 20, 2016 at 02:09 PM

@matthrewp Just a side note what might cause the problem is that you have gravity on but constraint movement on the y-axis. So this might conflict with the movement. As for the bullet's movement maybe try adding a script to the bullet using something like. rigidbody.addForce(vector.forward * projectilespeed, Forcemode.Force);

Something like this let me know I'd like to help :D

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

Follow this Question

Answers Answers and Comments

87 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 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 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 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

bullets acting weird when spawn 2 Answers

Add velocity relative to ground? 1 Answer

trouble making a fast projectile 2 Answers

Why are these object passing through each other? 1 Answer

how to make a bullet reflect off a wall? 4 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