• 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 jacksmash2012 · Nov 13, 2012 at 01:53 PM · collisions

how to fix collisions when movement is too fast?

Basically, I have two objects. Both have Box Colliders and RigidBodys attached. The mass for each is 0.1. Collision Detection is set to Continuous Dynamic for the moving object and to Continuous for the objects with which it collides.

The first object is essentially a bar that the user can move with his finger. The second is basically a cylinder (kind of like a hockey puck). The first (bar) object has a script attached where MovePosition is called within FixedUpdate (based on the touch locations).

Problem is, if the user moves the bar too quickly, it basically travels right "through" the cylinder and doesn't move it at all. If the user moves the bar slowly (or relatively slowly), collisions happen as expected.

Is there something I'm missing?

Comment
Add comment · Show 9
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 Cool Dave · Nov 13, 2012 at 04:24 PM 0
Share

I'm not sure if this is the problem, but you perhaps shouldn't be using Translate, if you are. Use some kind of Lerp or something, look it up in the docs. Hope this helps.

avatar image jacksmash2012 · Nov 13, 2012 at 04:29 PM 0
Share

Thanks. I could have made it clearer, but I'm using RigidBody.$$anonymous$$ovePosition, so that shouldn't be an issue.

avatar image Cool Dave · Nov 13, 2012 at 04:34 PM 0
Share

Have you read the description on RigidBody.$$anonymous$$ovePosition?...

For kinematic rigidbodies it applies friction based on the motion of the rigidbody. This lets you simulate moving platforms with rigidbodies sitting on top of the elevator. If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function.

...Have you tried using any other ways, like Lerp, etc.?

avatar image jacksmash2012 · Nov 13, 2012 at 04:48 PM 0
Share

Yep - read the description. I find it a little confusing, but the part that stuck out to me was this: "If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function." That seems to describe what I'm trying to achieve. (?)

I can look into using Lerp and see if it helps. Thx.

avatar image Cool Dave · Nov 13, 2012 at 05:08 PM 0
Share

Umm...You are doing the moving in FixedUpdate not Update, right? And your rigidbody is set to kinematic?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Eric5h5 · Nov 13, 2012 at 04:33 PM

Any moving objects must be set to ContinuousDynamic, not Continuous, and any object they might hit should be set to Continuous.

Comment
Add comment · Show 2 · 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 jacksmash2012 · Nov 13, 2012 at 04:45 PM 0
Share

Yes, that's correct. I apologize - I mistyped that in my original question. Will edit.

avatar image VipHaLongPro · Apr 10, 2015 at 04:20 PM 0
Share

This might work in a limited high speed but when it goes really too fast, this still does not work for me. (I tried shooting out my bullet at a velocity of 150 and it failed to detect the collision - both OnTriggerEnter and OnCollisionEnter don't fire). The target is almost still, when it's moving there are just few collisions detected (not acceptable). I think when it's too fast, the line may be very straight so we can use Raycasting to detect the hit point and don't use Rigidbody.velocity to move the bullet.

avatar image
0

Answer by keshav2010 · Nov 20, 2019 at 07:20 PM

You can use this strategy too 1. Keep track 2 positions, Position at currentFrame (say call it Pa) and Positition at previousFrame (Pb) 2. now, cast a ray starting from Pb to Pa 3. if ray hits any collider, get the location of hit point ( P_hit) 4. set Pa = P_hit, i.e move ur player back to P_hit because Pa is invalid (you cannot pass through collider)

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 Bunny83 · Nov 21, 2019 at 03:10 AM 0
Share

This has been solved ages ago. DontGoThroughThings. By ages I mean 12 years ago

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Checking Child collisions through parents 1 Answer

Collision angle of collided 1 Answer

iOS Rididbody Collisions 0 Answers

2D platformer levers and moving platforms question. 0 Answers

Applying a force to multiple rigidbodies at once. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges