Space Engineers

Space Engineers

83 ratings
FOC My Buddy - Follow Companion Drone AI
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
522.158 KB
27 Apr, 2017 @ 4:22pm
22 Dec, 2020 @ 9:27am
4 Change Notes ( view )

Subscribe to download
FOC My Buddy - Follow Companion Drone AI

Description
About:
Script to follow a player around. It's a mostly functional derpy drone script to get your drone to follow you around and bash into things. Range is limited to sensor detection which is 50 meters.

An overly complicated script which reads the sensor data for last detected entity and does some basic vector math to adjust the entity position. Afterwards it loads adjusted vector as a GPS location into the Remote Control block and sends it to the location!

I've been working on attempts at super cool drones to do tons of things and this is as far as I got. This is more or less some code I've been testing to make block tagged naming a little easier whether looking for specific tagged blocks or randomly grabbing a block, saving data into storage and customdata, learning/understanding vector math, button toggles, argument fun, etc.

Yes it's been done before, but I didn't see any on the workshop that were up to date and working.
Looks like one of the others was updated! Behind You


Setup
  • You need a sensor! We'll set up the Max Detection ranges if you didn't!
  • You need a Remote Control block, we'll mess with "Flight Mode" being set to "One Way", Collision Avoidance and Precision are at your preference.
  • Thrusters to move around!

Configurations
If the programmable blocks CustomData field configuration settings will be loaded in there. If you make any changes be sure to recompile or run the program with "LoadConfigs" as the argument.
Here is an example of the configurations loaded into the CustomData field.
CheckDistance = 6
AltitudeDistance = 3
BehindDistance = 4
Hybernate = false
VelocityPrediction = true
LocalGrid = true
WriteDisplay = true
PriorityTarget = none
  • CheckDistance - The distance in which the drone will start to follow you in meters. If you are more than 6 meters away, or the number set for CheckDistance, the drone will start following you! There has also been a failsafe added where your drone will also use this number to check if it should stop following you and switch the autopilot off in case the autopilot has lost it's mind. (Might be a bug in the script where it take a few cycles with VelocityPrediction enabled, I think it's something with how I tried to optimize the routines)
  • AltitudeDistance - The height offset, in meters, the drone will attempt to get to in relationship to it's target while in gravity.
  • BehindDistance - How far back your drone will try to stay from you in meters. In gravity the offset should be perpendicular to the direction of the gravity vector or ground. Your drone may stop before reaching this distance depending on the CheckDistance and the delays between script executions.
  • Hybernate - This will toggle the drone to follow you or stay put for a bit. This should be triggered with an argument either ToggleHybernate, HybernateOn or HybernateOff. If you are going to mass produce companion drones you may wish to set this to false to keep your drones from running off of the assembly line. This configuration is a boolean variable in the script and can be set to true or false.
  • VelocityPrediction - This is an experimental setting, use it at your own risk. I had a lot of fun testing this setting and am not sure how it will react with all drones. Basically what it does is uses the velocity vector to semi predict where you are going. Since this script uses the remote control block to set waypoints the locations have to be offset quite a bit for the remote control block to keep it's speed. If you slowly accelerate sticking within the 50 meter sensor limit your drone should continue to follow and keep up with you at a speed of 100m/s! It may take some getting used to and slight variations with your direction and the drones may be slightly off you'll need to adjust your direction to help the drone stay in range. One of the problems that makes this setting a bit iffy is we're triggering this script at the longest update cycle of 100 ticks, which is just over a second, any big changes like slamming on your dampeners when going 100m/s may confuse the drone. Be sure to set your drones antenna range to at least 3km as the tick delay may confuse parts of his miniature brain. If you do slam on your dampeners stay put for a minute your drone should go to the last location he saw you at!, just be careful he might be coming in too fast and not notice you in time to stop.
  • PriorityTarget - This is something I wanted for a while, your drone can now distinguish between you and another player! This is mainly useful for multiplayer where everyone in your group may want their own follow buddy. Previously the drones would follow the last detected sensor target. I also recall issues with drones sometimes trying to follow dead wolves or saberoids, this should fix that too! This should take your steam name, not 100% sure, and it is case sensitive! If you are having problems with this the script should list all the detected entities if the priority target cannot be found, so skim that detailedinfo section in the terminal for your name and related messages!

Setup Optional
  • Multiple Sensors and Remote Control Blocks should have MyBuddy or a random one will be used.
  • Want it to play a cool drone sound when it's trying to follow you? Set up a sound block with one of the in game drone sounds on a 30 minute loop! Add MyBuddy to the name to target a specific sound block.
  • Want the info from the terminals detailed info section on an LCD? Place an LCD on your companion and add "MyBuddy" to it's name.

Arguments:
  • ToggleHybernate - Used for button control to enable/disable follow mode.
  • HybernateOn - Requested Option to enable hybernate mode, no toggle.
  • HybernateOff - Requested Option to disable hybernate mode, no toggle.
  • Goto <GPS string> - Sends drone to GPS location, if a player is detected it will stop heading to the route.
  • LoadConfigs - This will load any changes made to the Custom Block, recompiling the script will also load changes.
  • UpdateConfig <Variable>, <Value> - Makes changes to CustomData ONLY, primarily used for debugging it's just an interface to the UpdateConfig method.
  • BuildConfigs - This will build the configurations in the CustomData field. Primary use would be debugging, another interface for a method.

  • Help - Help message basic list of arguments sent to detailed info via Echo. *verboseoff to read the info*
  • Settings - Writes some settings to detailed info via Echo. *verboseoff to read the info*

  • VerboseOn - Turns Verbose On (Default On)
  • VerboseOff - Turns Verbose Off
  • DebugOn - Turns Debug On (Default Off)
  • DebugOff - Turns Debug Off
  • Set <string setting> <float value> - Change some of the settings, was primarly used before customdata configs.
  • Get <string setting> - Change some of the settings, was primarly used before customdata configs and for testing.


Additional Comments:
Check out my workshop for other nifty creations!
See it in action with Jeremy the derpy follow companion!

mod.io here[spaceengineers.mod.io] Let me know!
here[www.hilands.com] is the zip file I used for mod.io
here[www.hilands.com] is the source cs file.
61 Comments
General Furry 5 Aug, 2023 @ 5:48am 
is this obsolete with automaton?
Акира 10 Mar, 2022 @ 9:26pm 
Drone not follow
MoonLiteNite 20 Jan, 2022 @ 9:53pm 
I am not having any luck. Never have issues with scripts and call myself advanced, i understand coding in general (VBS, HTML, etc..).
No issues with compiling this but no matter what config i have on the chip, names, or custom data, i end up with the output on Int system... everything looks good but if i keep scrolling down, i get an message about we must have a sensor block.
Then right below that is the "caught exception...." of a script object not set to an instance of an object at Program.Main(string argument at sandbox.game.entities.blocks.myprogrammableblock.M< .....

And yeah no luck, nobody else seems to have posted any problems. no major patches have come in while that would break this :D
nlstag 27 Apr, 2021 @ 2:20am 
Pro Tip: Apply turret to drone
Rhimens 20 Mar, 2021 @ 12:33am 
Seems to work, but not when its follow target is sitting in a chair on a ship. I want to build a drone army to follow me into battle, but my drone won't move! :(
Raysansterminal 20 Feb, 2021 @ 12:28pm 
///////////////////////////////
THIS IS A QUESTION MAINLY FOR THE AUTHOR
//////////////////////

So, I have come across this BP with a very interesting script thats half broken and half functional.

Link: https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=1142629224

The product above uses some sort of code that lets it HOVER, but the follow function does not work. Is there a way to make that blueprint work with JUST your script?
If so that would be AMAZING because then people would be able to make single thrust drones that follow them in planets thus making your script EVEN better <3

- Ray San <3
BinaryKiller Recoded 11 Jan, 2021 @ 5:26am 
Awesome!!! Would be so nice to have a drone that can light up stuff for you while you work on things in the middle of the night, because I need most of the power for my self :D Any way it will protect you by installing a turret?
BonTheMimic 23 Dec, 2020 @ 12:08am 
Also Phill it works
BonTheMimic 22 Dec, 2020 @ 5:35pm 
Tha k you phillni frocking livet you thank you do much
the-phil  [author] 22 Dec, 2020 @ 10:22am 
Sorry for super late responses, been super busy pretending to be an adult and ignoring workshop things as I tend to get addicted to this stuff!
@WOLFIE9211 - mod.io link above, let me know if it works. Couple more links to the source if that helps.
@BinaryKiller Recoded - currently I don't have it triggering any lights, eeeh, my main goal atm is to keep things super simple. Maybe have it trigger a timer when the hybernate toggles so players can drag and drop a bunch of block features to that, added to my future to do list.
@ShuttleCrossing - ignore the warnings, new update should compile without complaints
@Stack Trace - thanks for posting the workaround you rock!
@miner_sd - most likely the warning stuff fix it live
@NineSevenFive awesome!
@Dragon currently no plans for turret entity fancy stuff on this script/project. Definitely possible, but a bit complicated and some of it is over my pay grade. If I ever can figure it out I'll have a new project up for that.