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 /
avatar image
0
Question by RoughDesign · Jul 09, 2011 at 01:32 AM · collisionspeeddetection

Collision too slow

I am creating an upscrolling space shooter (2D).

The problem is, my bullets go through the enemy and get destroyed like 2 centimeters behind the enemy.

I use this peace of code to detect if my bullet collided with an enemy:

 function OnTriggerEnter (Target : Collider)
 {
 if (Target.tag == "Enemy")
     {
     Target.gameObject.SendMessage ("GoodDamage", 1.0, SendMessageOptions.DontRequireReceiver);
     Destroy(gameObject);
     }
 }

I found answers saying to change collision detection, but that did not help. Everything "functional" works(calling "GoodDamage" & Destroy), just destroy is executed way too late. I'm especially wondering because frames/second are at least 250 and I am thinking there must bee a lot of frames where the bullet is right inside of the collider.

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
1
Best Answer

Answer by aldonaletto · Jul 09, 2011 at 03:34 AM

Try to reduce the bullet velocity just to check if it's really a delay problem. Another possibility: check if the model and the trigger are correctly aligned (sometimes we use the model childed to the trigger object, and they may get inadvertently misaligned)

Comment
Add comment · Show 4 · 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 RoughDesign · Jul 09, 2011 at 01:01 PM 0
Share

O$$anonymous$$ I guess you already assumed that, but the collider for the bullets was behind the bullet (Z=0.15).

But while creating the prefab, I had to adjust the collider this way so it would be in the center of the gameObject. In playmode, the collider is centered perfectly with coordinates (0,0,0). Do you know why I have this coordinate difference between scene view and game view?

However, it works now, so thank you!

avatar image RoughDesign · Jul 09, 2011 at 01:11 PM 0
Share

Oh also for information, my gameObject has the collider and a plane with texture as a child. Rotation and position of the gameObject are (0,0,0), scale is (1,1,1). The plane also has position (0,0,0), its rotated around Y 180° and scaled to 0.02.

(So I think its not a child problem...)

avatar image aldonaletto · Jul 09, 2011 at 03:29 PM 0
Share

Strange thing this position shift: the settings defined in Scene view should be kept in Game view - I've never saw such a misalignment.

avatar image RoughDesign · Jul 10, 2011 at 08:02 AM 0
Share

Haha yeah that's what I thought. Now that I know, I can work with it, no problem. But I'll make a new question, maybe someone knows whats happening...

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to maintain collision while moving the player? 2 Answers

Best practice for OnTriggerEnter detection 1 Answer

Collision update speed 0 Answers

Collision not working 3 Answers

detecting rigidbody collsion with no extra script 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