PhysX Add Joints
From C4 Engine Wiki
Contents |
Introduction
Implementing joints is reasonably straight forward but a little bit quirky. This is the final structure that we want to achieve.
Add Sections
Open the PhysX-Base.wld in the World Editor, that is included in the downloaded file, and create three primitive boxes, resize them so that they look something like this.
Create a cylinder in viewport 1 (press ctrl-1 if you want the viewport fullscreen), make sure that it is quite narrow and not too long as we are going to make the joints for each part of the tendril. You can size the length in either viewport 2 or viewport 3. Press ctrl-I and make sure that it has the Physics Body Controller enabled, you can leave the properties for now as the default ones will be applied.
Once created, select the cylinder and press ctrl-c followed by ctrl-v for copy and pasting.
Move the newly pasted section down so it follows on from the first one, look in viewport 1 and make sure it is aligned directly over the first section.
The next part is the clever part, if you press ctrl-v it will remember where the initial copied part was moved to and paste the next one where it thinks the next part of the pattern is. If this one is correctly positioned, keep pressing ctrl-v until the sections are almost touching the floor.
So it looks like this.
Go back to the first section, select it and press ctrl-i select the Controllers Tab and check kinematic This will make sure that it will not move unless we program it to do so, but will act as a physics body anchor for the joints.
Add Joints
From the markers section, select a ConnectionMarker and place it dead center using the viewports 1 and 2.
While the ConnectionMarker is still selected, press ctrl-I and from the Controllers Tab, select Joint, leave breakable unchecked.
Select the Properties Tab and select Spherical Joint and Assign
Select the Connectors Tab and click new twice, change the types to Geometry and add a couple of names, although this isn't needed, I used act1 and act2 respectively.
Click Ok
Now, using the copy and paste technique that we mentioned earlier, you should be able to move the copied marker to its new location and ctrl-V to create another one in the correct position lower down, if it is in the correct position, repeat until all of the sections have a joint between them.
Attach the joints
Select the first joint, it is easier to use the 3 views here. I reduce the top right so only the connectors are visible (the geomtery is reduced), I zoom in the bottom left so that the sections are visible, and I use the the top right for connector selection.
With the first joint selected, press the Select and Connect button and a connector appears top and one appears bottom - this happens in all of the windows.
But, you cannot select the nodes in any window, bar the first one (??), select the top connector, and while it is highlighted, use the bottom left window to click on the section (the first is the kinematic one you want to connect it to) and press ctrl-L linking the connector, and a series of arrows are drawn. If other geometry gets in the way, just press ctrl-H to hide it when selected.
Click on the bottom connector (from the top viewport) and select the section below the previously selected one, press ctrl-L.
Complete the Structure
Repeat this until all of the joints are configured correctly and it looks like this. (All the joints are selected for the image)
Save the world and run the game with the new world. If everything has worked correctly you should be able to shoot the tendril and it should respond by moving around. If when starting the world, the tendril falls to the ground, then, a joint has been positioned incorrectly - work through them until you find the offending one and correct it.
Add Breakable joints
Select the first joint and press ctrl-I, select the Controllers Tab and click breakable, change the force value from 2000 to 200 or even 100 if you cannot break the connection with the standard weapon.
Run the world again and when you shoot the joint it will detach from the kinematic anchor.
Finally
Using the copy and paste technique, select all of the tendril sections and joints, and paste it along the structure. It's a bit of an art form, but quite easy once you know how.

















