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 Hamesh81 · May 21, 2013 at 05:26 AM · objectvelocityspeedmovekinematic

How should I move an object that parents on collision?

I have a projectile which when fired will parent itself to the object it collides with, rotate according to the normal it hit (detected via raycast), and then activate the relevant decal renderer which is a component of the projectile (not instantiated).

I was using a rigidbody for the projectile and turning it to kinematic when it collides. The problem is of course that because it is colliding with non kinematic rigidbodies and parents itself to them, it transfers some of its force and causes the rigidbodies to always jitter. I think I need to make the projectile a non rigidbody for this to work (if I can still do this with a rigidbody than please let me know). The second problem is though that I was using rigidbody.velocity to move the projectile before, which got fired by a function whenever an input was pressed (not directly in update). If I simply replace this with:

 transform.Translate(Vector3(0,0,speed) * Time.deltaTime);

because the function only gets fired while the input is pressed, the projectile doesn't actually translate anywhere. Is there a way I can set an instant velocity to a non rigidbody, which doesn't use update?

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 Tomer-Barkan · May 21, 2013 at 07:43 AM

You can set the projectile's collider to trigger by setting the "Is Trigger" checkbox in the inspector (and leave the rigidbody)

This way, the projectile will not use the physics engine collision resolution, and you'll have to manually decide how to resolve the collision (which seems to be what you're doing anyway).

When a trigger collider collides with another collider (trigger or regular), the function OnTriggerEnter() is invoked on BOTH of the objects. So be sure to implement your code in OnTriggerEnter() instead of OnCollisionEnter(). Note that the function receives a Collider instead of a Collision.

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html

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 Hamesh81 · May 21, 2013 at 09:25 AM 0
Share

Ah, ingenious! I hadn't thought of turning of the collider, but as you said I don't actually use it for collisions (I have the raycast for that). Thanks a lot

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

14 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

Related Questions

How to determine the axis specific speed (or velocity) of a kinematic object? 0 Answers

Move Object A towards Object B at a definite speed 1 Answer

Pushing and object up/down/left/right at constant speed 0 Answers

Can an object to transfer to another as it increases your speed? 1 Answer

Why do my objects keep changing speed? 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