• 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 Cherno · Jun 04, 2015 at 02:28 PM · rigidbody

Projectile needs to register collisions with rigidbody and non-rigidbodies

I have an arrow that flies in a straight line. It has a script that should apply damage and destroy the arrow when it hits an actor or a wall (or any other obstacle).

Problem:

Since it moves and needs to register collisions, it needs a rigidbody. This means that it will actually push rigidbodies or CharacterControllers (such as actors) away, even if the arrow object is destroyed immediately afterwards. This is not wanted. I could give every actor a seperate trigger collider and make the arrow's rigidbody non-kinematic, but then I can't register collisions vs. non-trigger colliders (such as walls).

So basically the question is, how can is set up the arrow so that it registers collisions with rigidbodiey/CharacterControllers (actors) AND normal (mesh)colliders (walls, obstacles), without pushing the former out of the way (= applying physics)?

Comment
Add comment · Show 7
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 Glurth · Jun 04, 2015 at 02:35 PM 0
Share

Is there a reason you arrow must have a rigid-body? You can always add multiple colliders to ANY object, regardless of weather or not it has a rigidbody component. I will usually add one collider that is a trigger, and one that is not a trigger, if I want to cover all types of possible collisions.

Alternatively, you could set the mass of the arrow to zero, so it does not impart any momentum.

avatar image Cherno · Jun 04, 2015 at 02:48 PM 0
Share

Thanks for the comment. I added a rigidbody because I don't know how else to make a non-static (since it's a moving projectile) object register collisions. So yes, I could add a trigger to my actors and set the arrow's RigidBody to be non-kinematic, but then I'd have to use OnTriggerEnter on the actor's script, and also the arrow wouldn't be able to collide with walls since they can't use a trigger collider. It also seems liek a rigidbody's mass can't be set to exactly zero.

avatar image Glurth · Jun 04, 2015 at 02:52 PM 0
Share

That's true, with two collider types, you would need to override both collision and trigger functions, but so what... put the damage functionality itself in a single private function that you can call from each collision function, with one line.

avatar image Cherno · Jun 04, 2015 at 03:12 PM 0
Share

I still don't understand how the arrow could register collisions with walls and obstacles which can't have trigger colliders :(

avatar image Glurth · Jun 04, 2015 at 03:30 PM 0
Share

Those obstacles must have SO$$anonymous$$E kind of collider, weather a trigger or physics collider- that is unavoidable. Since your arrow will have BOTH a trigger collider AND a physics collider (you will need to add at least one of these colliders manually, using "Add Component"), it can detect collisions for both types.

avatar image Cherno · Jun 04, 2015 at 03:33 PM 0
Share

I see what you mean now Of course walls etc. have mesh colliders. I didn't realize you meant that the arrow object needed a trigger and non-trigger collider. I was thinking taht the actors needed it ins$$anonymous$$d.

Thanks again for the suggestions. I will try it out and convert your first comment as an accepted answer if it does work :)

avatar image Glurth · Jun 05, 2015 at 12:56 AM 0
Share

Oops, I was certainly NOT clear about which object to put the two colliders on, my bad. Looks like we are on the same page now though :) If it works, and you accept it as the answer, I'll edit it to clarify that point.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Custom gravity based on normal vector and rigidbody.addForce 2 Answers

Weird collision with objects passing through each other 1 Answer

Making 3D Objects Stick On Other Objects Like A Grid? 2 Answers

Detect a GameObject Passing Between Other Two GameObjects? 4 Answers

Multiple connected body on fixed joint 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