Hi everyone, I’m currently working on a project for Rust modding. I’ve created some test elements in 3D using Blender, imported them into Unity, and generated the prefab. I’ve placed the prefab in a directory within the server’s folder, but unfortunately, I haven’t been able to spawn the object in the server. I’ve tried changing the directory path multiple times without success. Below, I’ll share the code I’m using to spawn the GameObject.
The idea revolves around a hot air balloon, but it’s different from the existing one. It’s a balloon that will rise on its own, similar to the Sky Lantern, but it will also launch fireworks and display custom flags with images from URLs (similar to how some plugins allow images on picture frames).
I’m already a developer, but I’ve never worked with games before—this is my first project. I couldn’t find any tutorials on how to add prefabs to the server. (I’ve seen that it’s possible to add them via RustEdit, but my idea isn’t for a static object. It’s an item that players can carry in their inventory and use with a mechanic similar to the Sky Lantern or the Hot Air Balloon.)
Here’s the code I’m using to spawn the object:
using Oxide.Core.Plugins;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("SpawnPrefab", "SeuNome", "1.0.0")]
[Description("Spawna um prefab existente no Rust")]
public class SpawnPrefab : RustPlugin
{
[ChatCommand("spawncubo")]
private void SpawnPrefabCommand(BasePlayer player, string command, string[] args)
{
string prefabPath = "server/servidor_modded/assets/cubaoo";
Vector3 spawnPosition = player.transform.position + (player.transform.forward * 3);
var entity = GameManager.server.CreateEntity(prefabPath, spawnPosition, Quaternion.identity);
if (entity != null)
{
entity.Spawn();
SendReply(player, "Prefab spawnado com sucesso!");
}
else
{
SendReply(player, "Erro ao spawnar o prefab.");
}
}
}
}
Error I receive when using the "/spawncubo" command in the game.
--------------------------------------------------------------------------
Directory of the prefabs I’ve already tested, including the "Small Rocket," which I downloaded here from the forum, and I also can’t spawn it in the world without RustEdit. It shows the same error in the console. I’ve tried adding ".prefab" at the end of the path, but the same error persists.
--------------------------------------------------------------
One of the balloon models that will be added.
------------------------------------
Edit.
The error lies in the way I’m exporting from Unity. Rust is not recognizing it, as even RustEdit couldn’t identify the .prefab. However, it did identify the prefab I downloaded here, the "Small Rocket."
I would greatly appreciate any guidance or suggestions on how to get this working. Thank you in advance!