In this quick Cinema 4D Xpresso tutorial you will learn how to set your object position according to length of an editable spline…
Insert your object. While your object is being selected right click an add Align To Spline tag and add an xpresso tag. (Both can be found under Cinema 4D Tags)
Click on your xpresso tag and add userdata into it. We need to two variables in this example. Length and Position. Length is only showing us length of a spline. You will able to change object position via position slider from your userdata. Your Length userdata variable type should be String and Position userdata type should be Float – Real.
Now double click on your xpresso tag and drag & drop align to spline tag into xpresso editor for twice. Also make sure to add your userdata into Xpresso editor.
In your xpresso editor add spline node from X-Pool – System Operators – Xpresso – General – Spline. Connect output of Spline Path variable (of Align to spline tag) to Spline node’s input value of Object. We should also add length output by right clicking output (red square in selected xpresso node) and selecting length option. Now we are going to connect this length value to our userdata Length string for informative purposes. Now on your Xpresso node add an output for position. Create a math (divide) node and connect Xpresso node position output to Math Input 1 and connect Spline Length output to Math Input 2. Then connect Math output to our second Align to Spline tag node’s Position value. You can add this value by clicking our second Align to Spline Node’s Input (Blue Box) – Tag Properties – Position.
Lastly create your editable spline and drag and drop it into Align to Spline tag’s Spline Path input.
Please check tutorial images for better understanding;
[image_frame style=”framed”]http://creativetuts.com/wp-content/uploads/2014/12/spline01.png[/image_frame][image_frame style=”framed”]http://creativetuts.com/wp-content/uploads/2014/12/spline02.png[/image_frame][image_frame style=”framed”]http://creativetuts.com/wp-content/uploads/2014/12/spline03.png[/image_frame]
You may download sample template file below.
[wpdm_file id= 56]