5
$\begingroup$

I want my locomotive to follow rails over a hill. The loc should always be on the rails. I've tried a few things (such as https://www.youtube.com/watch?v=OruVKMGGPX8), but I always come back to the same problem: the locomotive follows the rail, but leans into the curve:

How can I fix this?

$\endgroup$
1
  • $\begingroup$ blend-exchange.com is the place to upload .blend files to be shared. Once uploaded, copy the generated link, edit your question here and paste the link in. Well prepared and explained screenshots can also help. $\endgroup$
    – Booth
    May 31, 2023 at 13:14

3 Answers 3

4
$\begingroup$

If your curve is flat you can simply change the curve type to 2D to ignore the tilt for each control point:

enter image description here

If it is 3D and you want to keep it that way, you need to reset the tilt of each control point that isn't set to 0 degrees:

enter image description here

EDIT: You can also try setting the Twist Method to Z-Up.

EDIT 2 (after seeing the blend file):

Start with applying all transform on the curve (CTRL + A > All Transforms), then set the Twist Method on the curve to Z-Up. Then you'll have to tweak the Z-rotation of the locomotive to make it line up with the track, something like -28 degrees seemed to do the trick for me.

$\endgroup$
7
2
$\begingroup$

if you delete your path constraint and if you use a bone and use follow path constraint like this:

enter image description here

and apply scale + rotation for curve + locomotive and use edit mode to place the locomotive exact on the rails, you will get this:

enter image description here

enter image description here

$\endgroup$
5
  • $\begingroup$ I investigated WHY it works, because to my understanding it shouldn't… So apparently the real solution is to apply the rotation of the curve and - which you don't mention, but you did it - set twist method to z-up. The twist didn't work for me when I tried it, because I was unaware of curve's rotation. And this is what Tobias Einarsson said in the first answer in the thread 😜 $\endgroup$ May 31, 2023 at 19:30
  • $\begingroup$ uhm...just read...i wrote "apply scale + rotation for curve + locomotive" $\endgroup$
    – Chris
    May 31, 2023 at 19:32
  • $\begingroup$ Notice the - hyphen inset - is after the "and" in my prior comment :P $\endgroup$ May 31, 2023 at 19:33
  • $\begingroup$ Hey Chris, thank you for your help!!! I will try it out next weekend!! $\endgroup$ May 31, 2023 at 21:09
  • $\begingroup$ You are welcome! $\endgroup$
    – Chris
    Jun 1, 2023 at 4:32
1
$\begingroup$

I couldn't find anything on automatically aligning curve tilt to +Z, so you would need to use a complex geonodes setup, then, because apparently the constraint isn't affected by geonodes, you would need to capture the calculated tilt as attribute, make Python read the evaluated attribute and write it to the original geometry (and you would need to run the Python script after each modification of the curve)…

Or you could just align your object up using Geometry Nodes:

  1. Clear all rotations on your loco.
  2. Change Forward Axis of your tracking to $-x$, because that's the direction your loco looks at when you duplicate it and ⎇ AltP clear parent:
  3. Add Geonodes setup to your loco:

Of course you could animate it all in geonodes to begin with:

$\endgroup$
3
  • $\begingroup$ Hey Markus, thank you for your help!!! I will try it out next weekend!! $\endgroup$ May 31, 2023 at 21:08
  • $\begingroup$ @Capodelosplasticos consider my answer if you want to learn something new, but I think Tobias' answer is on point and most appropriate for your scenario. $\endgroup$ May 31, 2023 at 21:21
  • $\begingroup$ You've right, Tobias solution is very smart and also easy! But you have to find out first! Thanks anyway for your help $\endgroup$ Jun 3, 2023 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .