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 benk0913 · Jun 14, 2013 at 12:21 PM · collisionrigidbodybulletwalldecal

Bullet moves fast and makes a late collision..

For some reason, the bullets which I instantiate are detecting collision lately... So it shows for example the particle and decal which are meant to be spawned when it collided at first place abit further...

         lastBullet =(GameObject) Instantiate(Resources.Load ("bullet"),equippedWeapon.GetComponent<I_weapon>().gunPoint.position,equippedWeapon.GetComponent<I_weapon>().gunPoint.rotation);
         lastBullet.rigidbody.AddForce(-equippedWeapon.GetComponent<I_weapon>().gunPoint.transform.forward*Time.deltaTime*5000,ForceMode.Impulse);


Its force speed is Time.deltaTime*5000... I think that is the problem but I still cant be sure..

The bullet object is a rigid body and it uses a square collider.

The collision detection part: (The code is one of the bullets components)

  void OnTriggerEnter(Collider victim)
     {    
         
 
         
         
         //Hitting a concrete wall.
         else if(victim.gameObject.tag=="concrete" && owner!=victim.gameObject.GetPhotonView())
         {
              RaycastHit hit;
             if (Physics.Raycast (transform.position, transform.forward, out hit, 100.0f)) //Will pick the walls rotation and will draw a decal from it.
             {
                 Instantiate( Resources.Load("decal_concrete"),hit.point,Quaternion.LookRotation(hit.normal));
             }    
             
             Instantiate(Resources.Load("particle_concrete"),transform.position+transform.TransformDirection(0,0,10) , Quaternion.Inverse(transform.rotation));
             
         }
         
         Destroy(this.gameObject); 
         
     }

Please help me, how do I get the bullet to detect the wall at the moment it gets into it?

Comment
Add comment · Show 3
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 clunk47 · Jun 14, 2013 at 05:41 PM 2
Share

$$anonymous$$ake sure if you have a fast moving rigidbody, that the COLLISION DETECTION is set to CONTINUOUS DYNA$$anonymous$$IC. Any other rigidbodies that this bullet will collide with need to be set to CONTINUOUS. That should solve your problem. Another thing that could help on top of that, is making the COLLIDER component a bit bigger. One other way that could help even more, to get more realistic physics, turn down the TI$$anonymous$$ESTEP, only a bit at a time until you are happy with the results. Hope this helps.

avatar image benk0913 clunk47 · Jun 15, 2013 at 04:13 PM 0
Share

It does, with the time stamp,I already added the rest. And I dont wanna use the raycast for different reasons

avatar image benk0913 clunk47 · Jun 16, 2013 at 01:07 PM 0
Share

time step*

3 Replies

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

Answer by AntiLunchBox · Jun 14, 2013 at 01:10 PM

If the bullet is moving that fast, you might as well just forget using a collision with it. Just use a raycast from the gun to where it's pointing and do your code from there. It is more reliable than using collision on really fast objects.

You could also try using this script on Unity Community if you still want to use this method: DontGoThroughThings

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 bodec · Jun 14, 2013 at 05:46 PM 0
Share

Antilunchbox is correct this image may helpalt text

capture002.png (21.0 kB)
avatar image
1

Answer by lighting · Jun 14, 2013 at 02:26 PM

I'm doing similar thing but with flying arrow. What helped me to catch collision on time is increasing time resolution in Time Manager (Fixed Timestep). It affects collision detection as it's for physics.

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 benk0913 · Jun 16, 2013 at 04:39 PM

Well, I actually tried raycasting, it works much better than the bullet instantiating and solves alot of problems. I recommend the raycast method for bullet shooting.

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

19 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

Related Questions

RigidBody stuck on wall when jumped against 7 Answers

Smart camera? 1 Answer

A Bullet's rigidbody, hit.normal 4 Answers

Rigidbody of empty bullet shell collision problem. 2 Answers

Enemy rigidbody and bullet collisions 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