Setting up a vehicle to accept Arms - NeisesMike/VehicleFramework GitHub Wiki
A vehicle can have arms.
For example, there is the drill arm and the scanner arm.
Any vehicle can take arm upgrades if the player has enabled the ForceArmsCompat option.
But this option can lead to some weird outcomes!
Here you can learn how to make the arms play nice.
Overview
ModVehicle has the fields
public virtual VehicleParts.VehicleArmsProxy Arms { get; set; }
public virtual bool HasArms => false;
The HasArms
field is false by default. That means that a vehicle won't be able to accept arm upgrades without the ForceArmsCompat option. If you set HasArms
to true, then the vehicle upgrades will include two new arm slots.
This is the definition of the VehicleArmsProxy struct:
public struct VehicleArmsProxy
{
public GameObject originalLeftArm;
public GameObject originalRightArm;
public Transform leftArmPlacement;
public Transform rightArmPlacement;
public VehicleArmsProxy(GameObject originalLeft, GameObject originalRight, Transform leftArmPlace, Transform rightArmPlace)
{
originalLeftArm = originalLeft;
originalRightArm = originalRight;
leftArmPlacement = leftArmPlace;
rightArmPlacement = rightArmPlace;
}
}
The original*Arm fields should be set if your vehicle has arms that come standard. If you set these GameObjects, then the original arms will disappear when arm upgrades are added. The upgrade arms will replace the original arms. See the Crush for an example.
The *ArmPlacement fields dictate where upgrade arms should be placed. If you don't set these, then arms will flank the pilot position in a way reminiscent of the Prawn (they'll be about half a meter to the left and right of the player's piloting position). As usual, z-positive (blue arrow) points forward, and y-positive (greenish arrow) points up.
Example
This is the way Crush overrides the ArmsProxy field:
public override VehicleArmsProxy Arms => new VehicleArmsProxy
{
leftArmPlacement = transform.Find("LeftArmPlace"),
rightArmPlacement = transform.Find("RightArmPlace"),
originalLeftArm = transform.Find("Robot3/body.Low").gameObject,
originalRightArm = transform.Find("Robot3/body.Low.001").gameObject
};