Sandbox Entities

Started by garry · one year ago · 29 replies · 2,242 views

edited one year ago#1
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
A thread to discuss the creation, spawning and limitations of Sandbox Entities.

How to make a Sandbox Entity

  • Launch S&box Editor
  • New Project (top right)
  • Select Sandbox Mode Addon
Now you'll be in the editor with Sandbox and your addon loaded
  • If the Sandbox scene isn't open, go to asset browser, click on Sandbox on the left, then search for sandbox.scene and open it
  • Pressing play should let you play Sandbox like normal
  • In Asset Browser, in your addon's Asset folder, right click and go to new > Sandbox > Sandbox Entity
  • Name it whatever you want
  • Do it again, but create a new prefab.
  • Select your Sandbox Entity and drag the prefab into the Prefab field and press SAVE
  • Your SENT will now be spawnable in the game when you press play, under the Local tab

You can do whatever you want in your prefab now. If you want people to drag it around make sure it's got a Rigidbody.

When you publish, if you added custom code, like custom components - then tick the Include Code checkbox.



Papa Brickolini
Member
JoinedApr 2021 Posts90 Score6,401
Lot's of potential to make cool stuff
edited one year ago#3
ShadowBrain
Member
JoinedApr 2021 Posts32 Score6,513
Voice recognition => Safety/moderation check => Shake to submit to an LLM for answering.
Fun stuff!
edited:
(It would work a lot better if the voice recognition was better, it's VERY hit/miss right now)
edited one year ago#4
badandbest
Member
JoinedJul 2022 Posts23 Score575
What are the reasons you went for a custom gameresource over just using prefabs? 

Edit: I remember old add-ons just used a "spawnable" tag to differentiate them.
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
So they would be distinguishable from prefabs
100°c
Member
JoinedJul 2021 Posts25 Score910
People are getting this error when trying to use my sents

2025/09/02 21:59:51.9347    [Generic] Failed to fetch package info for gmodn.usables_hotdog: package not found.   
2025/09/02 21:59:51.9347    [Generic] Cloud: Package gmodn.usables_hotdog has no PrimaryAsset   


What would be causing this? I'm pretty certain I have my definitions set up properly.
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
Hmm, I wonder if that's when the Sent is created on staging but they're playing on the main branch?
edited one year ago#8
Beno
Member
JoinedMay 2023 Posts1 Score760
ild say so, had some enitiys not working on main and once i swapped to staging. they worked 
edited one year ago#9
Braxen 🐟
Member
JoinedJun 2021 Posts200 Score190
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Editor.AssetList.DrawAssetEntry(VirtualWidget item, AssetEntry asset) in C:\program files (x86)\steam\steamapps\common\sbox\addons\tools\code\Editor\AssetList\AssetList.cs:line 361
   at Editor.AssetList.PaintListItem(VirtualWidget item) in C:\program files (x86)\steam\steamapps\common\sbox\addons\tools\code\Editor\AssetList\AssetList.cs:line 298
   at Editor.BaseItemWidget.PaintItem(VirtualWidget item)
   at Editor.BaseItemWidget.OnPaint()
   at Editor.ListView.OnPaint()
   at Editor.Widget.InternalPaintEvent(QPainter e, Int32 flags)
   at Managed.SourceTools.Exports.Editor_BaseScrollWidget_InternalPaintEvent(UInt32 self, IntPtr e, Int32 flags)
Getting this when I try to search for the sandbox scene. On both staging and release. Can only find minimal scene in the everything browser.

Nothing happens when I try to select a prefab for the entity either, field doesn't populate.
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
I'll look into that
Braxen 🐟
Member
JoinedJun 2021 Posts200 Score190
I got it working after a few restarts but having real trouble with IDE analyzing, not recognising TypeLibrary/Log etc.

Nothing seems to happen when you call OnDamage on the IDamageable interface on the player either
Zontax
Member
JoinedMay 2023 Posts96 Score8,912
Braxen make sure that in your .csproj file you have
<ItemGroup>
    <Using Include="Sandbox.Internal.GlobalGameNamespace" Static="true" />
    <Using Include="Microsoft.AspNetCore.Components" />
    <Using Include="Microsoft.AspNetCore.Components.Rendering" />
</ItemGroup>
and maybe
<ItemGroup>
    <ProjectReference Include="D:\Games\Steam\steamapps\common\sbox\addons\base\Code\Base Library.csproj" />
</ItemGroup>
Because for some reason they disappeared from my addon project and I returned them.
100°c
Member
JoinedJul 2021 Posts25 Score910
Demo of a Mac 128k virtual machine running in the Sandbox gamemode, powered by Infinite Mac

I had to clone the contents of the Sandbox game so I could mess with the WebPanels properly but it's coming along quite nicely. Model is from Spicy Apple but is most likely to be placeholder since I don't know if I'm going to be able to get an original model made, I may just ask Spicy if I can use this one if I can't though.

Not sure how I would transfer over keyboard inputs, as WorldInput doesn't have support for that, but other than that it is looking nice.
Zontax
Member
JoinedMay 2023 Posts96 Score8,912
Is it necessary to create a subfolder with its own unique name in the addon project in the Assets folder and place other folders and resources in it (like Assets/zontax_addons/...)? Is this not necessary? Can there be path collisions that will turn into a problem, for example, if the resource in the addon has the same path as the resource path in the sandbox game itself or the same as in another addon?
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
It's not necessary, but it would be ideal if you tried to make your filenames as collision free as possible.
edited one year ago#16
Zontax
Member
JoinedMay 2023 Posts96 Score8,912
Although why should I worry sents? They are the same resources as others, and there are no problems with them
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
Alright I fixed some bugs on staging. Opening the addon should be a lot more stable now, should no longer get missing models and textures and effects, and the context menus should work properly.
100°c
Member
JoinedJul 2021 Posts25 Score910
 Functional Minecraft Sign :3
QuackCocaine
Member
JoinedJul 2021 Posts31 Score165
Would be neat if the old toybox download progress ui animation could be remade to show download progress of sents. 
Divined
Member
JoinedMay 2021 Posts22 Score105
Anyone that used UI with their entities yet that us noobs can take a peep at?
Kronax
Member
JoinedAug 2021 Posts6 Score1,237
I clicked on the asset browser, but I couldn't see sandbox.scene here. I also selected the target game `sandbox` and restarted the project.

garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
Are you on staging?
Kronax
Member
JoinedAug 2021 Posts6 Score1,237
nope
garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
Get on staging and give it a go m8
Sophia
Member
JoinedSep 2022 Posts69 Score4,378
anyone else unable to find the sandbox.scene file, type
install facepunch.sandbox
in console

garry
Facepunch
JoinedApr 2021 Posts453 Score2,355
Updated OP with new instructions
edited one year ago#27
Zontax
Member
JoinedMay 2023 Posts96 Score8,912
Braxen make sure that in your .csproj file you have
<ItemGroup>
    <Using Include="Sandbox.Internal.GlobalGameNamespace" Static="true" />
    <Using Include="Microsoft.AspNetCore.Components" />
    <Using Include="Microsoft.AspNetCore.Components.Rendering" />
</ItemGroup>
and maybe
<ItemGroup>
    <ProjectReference Include="D:\Games\Steam\steamapps\common\sbox\addons\base\Code\Base Library.csproj" />
</ItemGroup>
Because for some reason they disappeared from my addon project and I returned them.
Sophia
Member
JoinedSep 2022 Posts69 Score4,378
Made a car with the new seat, pretty easy to do actually
strangerdanger
Member
JoinedJul 2022 Posts1 Score2,255
entities custom code components don't seem to spawn or work correctly when it has the inventory pickup component
Zontax
Member
JoinedMay 2023 Posts96 Score8,912
Make Entities great again!
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.