Space Engineers

Space Engineers

FOC My Buddy - Follow Companion Drone AI
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.
BonTheMimic 28 Nov, 2020 @ 1:38am 
Anyone think they can copy this to mod.io
BinaryKiller Recoded 27 Nov, 2020 @ 7:01pm 
any way this thing can activate lights? In case it is in dark spaces
Rhimens 25 Apr, 2020 @ 12:56am 
Won't load since LCD text is deprecated. Is there a workaround?
Stack Trace 5 Mar, 2020 @ 7:15pm 
Comment lines 396 and 397


if (DisplayBlock != null)
{
//((IMyTextPanel)DisplayBlock).WritePublicText(strInfo);
//((IMyTextPanel)DisplayBlock).ShowPublicTextOnScreen();
}

creature 17 Feb, 2020 @ 10:07am 
appears to not be able to load
NineSevenFive 6 Jan, 2020 @ 3:11pm 
NineSevenFive 6 Jan, 2020 @ 3:02pm 
Quick question guessing this may be a little incompatible with speed mods due to remote control speed limits?
Dragon 8 Dec, 2019 @ 3:10pm 
@the-phil very nice mod, but i am wondering- do you think it could be possible to grab the target a turret is shooting at and turn it into a gps to automatically update an RC block? essentially, to make a drone that would try and stay a variable distance from whatever the turret is firing at?
the-phil  [author] 27 Sep, 2019 @ 9:44pm 
@Reigdaer sounds like it might be an issue with steam, been a bit slammed and haven't been able to test on my end.

As a work around try grabbing the code here MyBuddy [www.hilands.com]. Should be able save that file, open it with your favorite text editor, like notepad, then copy and paste it into the game.

Should be safe to ignore any compiler "warnings", if you get any "errors" let me know.
Reigdaer 20 Sep, 2019 @ 11:30am 
this is not longer working, i unsubscribed and subscribed and every time i try to copy the code, but no code is being copied
the-phil  [author] 18 Aug, 2019 @ 5:41am 
@relyt18005 Experimental mode must be enabled in the game settings (main menu>options>game>Experimental mode), in game scripts need to be enabled for the save (when creating a new world or edit the settings when loading; Click the advanced button in settings and search for a checkbox for In-game scripts).

If in game scripts are setup and enabled properly, place a programmable block you'll need to access the block in the terminals control panel. Select the programmable block click Edit, click the Browse Scripts button and double click the script from the list. The code will then be transfered to the programmable block, hit the ok button (ignore the warnings from check code if you get any). The script should automatically run and display some information in the detailed information section (bottom right area in the terminal).

I'd recommended trying this in a test world or at the very least saving your game before trying new things out.
Dadbot8710 17 Aug, 2019 @ 9:06pm 
i maed a srvr
Dadbot8710 17 Aug, 2019 @ 9:06pm 
can you help
Dadbot8710 17 Aug, 2019 @ 9:06pm 
im new so i do not know how to inport this
@the-phil Thanks for the reply! Just with very loose understanding of it all I was hoping I would have been able to jury rig something together, but seems a bit out of my knowledge league for now. Was able to get a linear follow system working with motion sensors though so that's doing the trick. Good luck on trying to get it all working!
the-phil  [author] 21 Jun, 2019 @ 1:21pm 
@GentlemannP1rate Antenna follow is definitely possible, not sure if it's in the scope of this project. You may want to look into "Formation System - Flight Follower" and possibly "Rdav's Fleet Command MKII".

I've fiddled around some with the old antenna network API and the more recent from 1.190. Think the part that got me was the desire to get all the rotations sending quaternion and matrix directions to keep the alignment of the following ships; then of course being able to have multiple drones in a set formation or a keeping a relative position. I've gotten some great code snippets to do some of the functionality, gyro rotations, the alignments, thruster movement, node reporting, and some basic formations but in all honesty I'm a noob with this stuff so it takes me a bit to get things working "right". It is definitely something I've been working on but don't know if it will come to fruition.
Hello friend! Would it be possible (or more, how hard would it be) for one to modify this so that the companion follows a certain named antenna instead of the player?
Thanks!
VertigOwl 18 Jun, 2019 @ 10:13pm 
ill give the sensor a check because i have mine set to have me as the priority. thanks for the tips ill give it a look over and get back to you
the-phil  [author] 14 Jun, 2019 @ 9:07pm 
@[GC] Paradigm Just tested it to make sure it was working on my end.

Couple things to try:

1. Sounds like the sensor setup to pick up more than players, make sure your sensor block is only set to pick up players. If your drone is acting like a dog scooting its butt in circles on the carpet it's most likely picking up the planet. Detailed information section of the Programmable block has a should output the Target. You can also set a PriorityTarget in the CustomData field to only have it follow a specified player.

2. Sometimes the Remote Control block glitches typically the drone will just turn to your direction and not move. Reloading the save or copying and pasting the grid should fix it. Typically it will just turn a direction and look at you.
VertigOwl 14 Jun, 2019 @ 3:25am 
Im trying to get the code to work but the drone just kinda flies around in random directions for a while like its lost or something. im not a code guy so i dont know why its doing so
TSM [EGC] 17 May, 2019 @ 10:40am 
this is fecking awesome i have a few of the ground encounters mods active so this make life easier as some of them spawn a Fighter :D
xelphyn 27 Mar, 2019 @ 1:38pm 
Can this be used to track a specific named beacon instead of a player?
the-phil  [author] 10 Feb, 2019 @ 11:55am 
@jperry998 & @Texasgrown04 unfortunately the remote control block doesn't work with wheels and this script uses the rc block features.
@Dr.MoonShine Cameras can use Raycasting features to detect players and other objects, however they work more like laser pointers. It's possible to get better range, but to counter the pinpoint accuracy you'd need more proccessing cycles.
Tex 3 Feb, 2019 @ 4:22pm 
Is there a way to make this work with wheels? Otherwise, AWESOME script!
RoasterToaster(Jet) 20 Jan, 2019 @ 5:40pm 
could it use a camera to find the player?
ShinyPhoenix998 12 Dec, 2018 @ 3:44am 
it was a problem that was my fault thanks for the help
And could you make this work with wheels?
the-phil  [author] 12 Dec, 2018 @ 1:13am 
@jperry998 have you tried adjusting the "AltitudeDistance = 3" variable in the customdata field of the programmable block and recompiling or running with the argument "LoadConfigs"? It's been a bit since I've tested the script, so I'm not sure if there have been many changes to the games remote control AI. Let me know if tweaking the custom data settings doesn't help.
ShinyPhoenix998 11 Dec, 2018 @ 3:46pm 
I have a problem with the drone keep on flying higher than what i want it to be and the drone has thrust in every direction and the drone is suppose to be a flying medium cargo contrainer but it wont work could i get some help?
Lathy...or is it 26 Aug, 2018 @ 2:56pm 
Also - someone should load MyBuddy onto a large grid like Big Red. Maybe it's just me, but I think it'd be HILARIOUS to have a huge ship following you around like a pet dog XD
Lathy...or is it 26 Aug, 2018 @ 2:55pm 
@the-phil LoL yeah, the size did get a bit out of control - I'm thinking of tryign to create a mini-version called Squirrel Monkey with the bare essentials for life. Also, glad to hear you like the Sky Rat ^_^ If you decide to use it in your project, post a link in the comments - I'm intrigued to see.

The new settings seem to work pretty well, btw. Thanks for looking into this.
One suggestion - when I write scripts that take settings from Custom Data, I add a command to initialize the Custom Data field with blank settings. You might want to add that to MyBuddy at some poin.

Thanks again - your code has made Capuchin a useful, if beastlike, helper drone.
the-phil  [author] 24 Aug, 2018 @ 1:42am 
@[PSI] BC holy moly Capuchin is a beast! Guns, O2/H2 generator, storage and a recharge seat!

I fixed up the CustomData field of the PB with this version. It's easier to edit configs and those configs are checked during world loads, recompiles, etc. I did a few minute test with Capachin and added this to the configs below, run with the argument LoadConfigs or recompile for changes to the customdata field to take. Turned off the close-in sensor and Capuchin seemed to be happy, tweak it to your likings Distances are all in Meters.

CheckDistance = 10
AltitudeDistance = 2
BehindDistance = 5
Hybernate = false
VelocityPrediction = false
PriorityTarget = none

Looks like I forgot to update the description with the config info, must be burried in the "change notes" up and over that way --->

I'll keep an eye out for your more drones on your workshop, the Ardoss Sky Rat looks awesome. Might use him as a test subject with some of the other projects I'm working on!
Lathy...or is it 23 Aug, 2018 @ 11:26pm 
@the-phil Glad I could help. This, btw, is my drone (or at least the atmospheric version) that uses your script https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=1484933698 The idea is to keep everything a player needs in survival at arms reach when out and about. You probably already have a testbed for your script, but if not, this one may be useful (you will have to turn off the close-in sensor - the script currently keeps trying to run me over, so i had to turn hibernate on when the drone got too close).

Cheers :)
the-phil  [author] 19 Aug, 2018 @ 5:06am 
@[PSI] BC 1) should be easy to do both a start and stop along with toggle good idea! 2) That looks like sloppy code logic. Nice catch! 3) I've started to see this more frequently with different ship designs using the RC block and Autopilot while messing with some other code. Setting a tick counter delay and a distance check to flip the auto pilot seems like a practical solution in my head. 4) I've been working on some gyro turning controls but I fried my brain on some of the basic math bits. With some ship vector to world matrix vector finagling and I should have it. I'd love to copy and paste it from something else, which has been tempting. However half of the fun, for me, is learning how to do it while bashing my head into a wall repeatedly trying to grasp some of these concepts!

A lot of cool things were added to the scripting API since I started this derpy code. I had an itch to come back to this project and spruce some of it up, excellent timing on the comment thanks!
Lathy...or is it 18 Aug, 2018 @ 9:57pm 
this is a really useful script, and has some nice, clear documentation built in. I have some suggestions, though, if you don't mind. Also, please imagine each of these begins with a 'please' and ends with a 'thank you' - the text is already dense enough without repetition ;) - 1) Add commands to start and stop hibernation mode instead of just toggling it. 2) Modify hibernation to cancel the autopilot. 3) Check the distance between the drone and the player periodically. When the distance is less than or equal to the stand-off setting, shut the autopilot off. This will prevent the current behavior where the Keen autopilot repeatedly overshoots its target, reverses, overshoots, and reverses. 4) Dump the autopilot altogether - hijack code from a missile script or other script that uses thruster and gyro overrides, as these are much better at getting to a destination without crashing or overshooting. This is the hardest one, though, which is why it's just a suggestion.
the-phil  [author] 24 Jun, 2018 @ 6:07pm 
@meowmeowkitty223 Should work fine with large or small grid ships. Slap on some turrets on your drone and this script might be semi useful for you, the script is really basic!
the-phil  [author] 3 Sep, 2017 @ 6:09pm 
@Noganite Just tested it with atmospheric thrusters and it seemed fine, Ion wasn't moving... umm... I switched Collision Avoidance in the remote control block and it "worked" (Also switched Autopilot to on which should auto toggle with the script, and Flight Mode set to One Way). What kind of drone did you build? I know wheels don't work, or didn't before, with the remote control block which the script relies on.

@remethep thanks for sharing the video, loved it! The flying pig for lonely players in space, thanks for the laugh!
Noganite 3 Sep, 2017 @ 5:01pm 
followed instructions to a T does not follow or even move. spent 3 hours trying and it fails...the Behind you script also stopped working randomly...code check shows errors.yours does not but had high hopes.
remethep 23 Aug, 2017 @ 5:37pm 
Two drones are featured in this video. :) https://www.youtube.com/watch?v=XrDxVoiAvPo&t=124s
DogwaterGaming69 20 Aug, 2017 @ 4:17am 
thanks
the-phil  [author] 19 Aug, 2017 @ 10:54pm 
@the_gamers_bo YT, I'll see what I can do about a video, my internet connection is horrible and takes about a day to upload a 10 minute clip. In the meantime check out the example blueprint Jeremy Atmospheric Drone Follow Companion you should be able to paste the drone in and it should work!