2
$\begingroup$

My goal is to create a two objects collision while the moving object(1) won't move in a straight line before it hits object 2. In order to make a realistic collision turning off animation's property is essential. You might say ok what is the problem check in which frame the collision happens and turn it off but I'm doing this using script and different size objects (and also orientations). Here is what I tried to do so far: 1) make a follow path constrain - the problem with this approach is when you turn off the animation the object goes off track and doesn't collide with object 2. I also tried to play with the influence parameter.

enter image description here

2) make clamp to path constrain - the problems here are the same as for (1) but with addition, the animation starts only in the 20th frame instead of the first one.

enter image description here

It seems like constrains and animations have some sort of relation between them, why can't the object follow the path after the animation is turned off? Let me try to be clearer I want the moving object to maintain it’s direction think of it as train on track when the engine is suddenly stopped working, the train will continue to move on the track. Since the train already developed speed it will take some time until the train will stop completely.

The solution doesn't have to involve python script I will be able to convert it after implementing it using the GUI.

$\endgroup$
  • $\begingroup$ Have a feeling, could be wrong, It is possibly beyond the scope of the physics engine to do this. A workaround re using physics engine deceleration could be to set up a straight line physics sim to drive the offset of train along curve using distance traveled by dummy. A thin plane with an array modifier set to fit curve creates the "runway" of approx same length as curve for the sim. $\endgroup$ – batFINGER Nov 15 '19 at 11:29
  • $\begingroup$ @batFINGER, In other words, you want to tell me that there is no way to simulate train crashes into a car or something similar to that. $\endgroup$ – AvivSham Nov 16 '19 at 12:49
  • $\begingroup$ Not at all. I'm suggesting that having an objectunder the influence of physics & follow path constraint might be outside what the physics engine is capable of. $\endgroup$ – batFINGER Nov 16 '19 at 13:22
  • $\begingroup$ As I wrote: in order to make a realistic collision you need to turn off the animated property which has some kind of relation to "follow path", how do you suggest me to do it? $\endgroup$ – AvivSham Nov 16 '19 at 14:24
1
$\begingroup$

I explored two ways of constraining a physics object to a curve:

1: A physics constraint connected to your rigid body is set to only travel and orient in a straight line. Animation Nodes and a python script moves and aligns that constraint to your curve every frame.

AN makes a mesh out of the curve then moves and aligns that physics constraint to the curve every frame. A python script is needed to work around an apparent bug to get the physics object location. It's a complicated setup. It works ok on a roller coaster type track. It may work better with tuning. It may work on yours. If you share your blend file, I'll share mine.

2: Simpler, no plugins: A hidden pipe track and ball(s) connected to your object by physics constraints.

Loft your curve with a bevel so that it's a tube mesh curve, with enough detail and room so that the ball travel in it smoothly. (make a copy of the curve so you can go back to it if needed) Convert to mesh and a physics object. The track is passive, mesh collision. no friction, no bounciness. Connect a constraint and fix it to your object, perhaps below the pipe track. your object's location should be constrained to the track, If you want your object to turn with the track, make two balls stick them in the pipe and connect them with a fixed physics constraint and connect your physics object. You can hide this pipe track and balls in your render. It's more complicated to have the angle matched to the curve in 3 axis. Perhaps have a rectangle block traveling down a square tube? Tested briefly, may work for some cases and with tuning, but a ball works so much smoother.

I have not tested or explored this completely but it should give you some ideas.

Edit: Tested 4 connected spheres forming a flat rectangle car, sliding in a square track, seems to travel smoothly and keep orientation.

Edit2: Which is similar to giving a rectangle a collision margin, It makes the corners of the "Box" collision object smooth. So that's easier to make and edit.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.