-
Notifications
You must be signed in to change notification settings - Fork 2
Using Custom Objects
Are you tired of the same old items in the game? Adding custom objects to your mod can breathe new life into the gameplay. Let's explore how you can make this happen.
Before diving into creating custom objects, make sure you've loaded your custom assets. If you haven't done this yet, follow this guide.
Once you've instantiated your object in the CustomObjectsRegistration method, you're ready for the next step.
If you want a standard object that can be picked up, placed, and so on, you need to do it like this.
public override void CustomObjectsRegistration()
{
base.CustomObjectsRegistration();
GameObject obj = Instantiate(LoadAsset<GameObject>("example", "example", "", ".prefab"));
ModHelper.Instance.AddBasicObjectLogic(obj, objName, objDescription, price, weight, canFindInCrates, canBuyInStore);
CustomObjectsManager.Instance.RegisterObject(obj, "ObjectID");
}-
canFindInCrates&canBuyInStoreare currently not available but should still be set.
You can adjust the object's position using these:
ModHelper.Instance.AdjustCustomObjectPosition(obj, throwRotation, position);
ModHelper.Instance.AdjustCustomObjectTrunkPosition(obj, position, rotation, dimensions);- All of the arguments, except obj, are Vector3s.
For AdjustCustomObjectPosition:
-
throwRotationspecifies the euler angles that the object will have, relative to the player once the item is no longer being held (dropped) -
positionspecifies the object's position relative to the player while being held
For AdjustCustomObjectTrunkPosition:
-
position&rotationspecifiy the adjustments you may need to make so that the object doesn't clip through the body panels/roof rack -
dimensionsspecifies the dimensions of the object, refer to this guide for more information.
If you made the object findable in crates or buyable in stores, once this feature works, it should appear there.
For manual spawning, use:
CustomObjectsManager.Instance.SpawnObject("ObjectID", position, rotation);-
rotationis a Vector3, as it modifies the euler angles. There is also aSpawnObject(ID, position)variant.
If you'd like to create custom engine parts, follow along.
- Full Linux guide
- Installing JaLoader via JaPatcher
- Installing mods
- Adding Custom Songs
- Custom Paintjobs