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
1
Question by phort99 · Mar 21, 2013 at 05:13 AM · physicskinematic

How to make kinematic body collide using velocity

I need to create a kinematic object where other objects react to it like it has a velocity and angular velocity. A normal Kinematic object ignores its rigidbody's velocity and objects that hit it act like it has zero velocity, so you can't push against an object and have it react as you expect.

I need a way to make a rigidbody that is not be affected by collisions with static and dynamic objects, but still affect the objects it hits, essentially a one-way collision. Collision layers only allow me to prevent collisions both ways.

Currently the Super-Kinematic object is marked as a non-kinematic rigidbody, and am doing some math based on the object's unrestrained motion to set the velocity, which are then used by the physics engine in collisions.

The problem comes as soon as the kinematic object touches the static parts of the scene. The physics engine reacts to the object penetrating the collider by pushing it up with a lot of force, giving it a high velocity that affects any collision with other objects on the same frame.

Here's my current script. The angular velocity piece isn't working yet so I left it out. This works until the object touches a static piece of the scene, at which point, anything it touches on the same frame is likely to go flying away.

 public class KinematicPhysics : MonoBehaviour {
     
     Vector3 prevPosition;
     
     // Use this for initialization
     void Start () {
         prevPosition = transform.position;
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         Vector3 dPosition = transform.position - prevPosition;
         rigidbody.velocity = dPosition / Time.fixedDeltaTime;
         prevPosition = transform.position;
     }
 }
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 Seth-Bergman · Mar 21, 2013 at 05:38 AM

You can attach a child object to the kinematic one and give that the collision, here's a simple example project, just play the scene if you like..

http://dl.dropbox.com/u/11203897/RigidbodyTest.zip

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 phort99 · Mar 21, 2013 at 03:25 PM 0
Share

Thanks, it turned out that rigidbody.$$anonymous$$ovePosition was the piece that I was missing

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

11 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

Related Questions

Projectile collides, freezes, but flips to weird angle. Help! 0 Answers

Realistic collisions with a kinematic rigidbody? 1 Answer

Switch off Kinematic for a Rigidbody in response to an explosion or impact? 1 Answer

Braketorque makes car behave like a kinematic rigidbody 0 Answers

Preventing objects from intersecting with minimal physics 3 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