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

Show more comments

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.

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

AddForce doesn't work 4 Answers

Make player walk on sphere planet 2 Answers

Camera Collision Not Working 0 Answers

My 2 Objescts doesnt collide 1 Answer

Instantiating a prefab as a component type? 2 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