Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
That said... What I did in the beginning was set up a grid with 2 cameras far apart each pointed at a specific point on the asteroid. Then use algebra and I could get close enough for my needs. Now its done using camera raycast which doesn't measure the distance to the asteroid, just tells you the asteroid location and using algebra to distance from your own location.
So... a simple script....
MyDetectedEntityInfo INF=Camera.Raycast(range);
double DISTANCE=(INF.HitPosition.Value-Me.GetPosition()).Length();
Indeed it could be useful for many things, including just identifying the closest asteroid to the current ship position, for whatever reason... but depending on the situation and reason, there could be alternative sources of information that could be equally useful.
I admit I was a little harsh with OP, but the opening question sounded like it was from someone who didn't know scripts or math, and its a requirement to know that.
You use the camera ray cast api https://forum.keenswh.com/threads/new-camera-raycast-and-sensor-api-update-01-162-dev.7389290/
- You select the camera you want to use.
- Check the camera can use the raycast.
- Use the Raycast function on the block
- Check the return value to see if it detected something in the given distance
- If detected, check the type of the detected object to be an asteroid.
- If asteroid Calculate the distance between your position and and the object position.
- Do something with with the distance you calculated.
You can also look at the outdated wiki https://www.spaceengineerswiki.com/API:Sandbox.ModAPI.Ingame.IMyCameraBlock (why would keen has an wiki to not update it...
Or the very outdated Open Source as doc
https://github.com/KeenSoftwareHouse/SpaceEngineers
But again why would keen keep it updated to help coders...
Best option is to actually install the MDK toolkit https://github.com/malware-dev/MDK-SE for visual studio
Or the one for VS Code https://github.com/gregretkowski/VSC-SE
As the intellisence will give you much much much better up to date and accurate information on what functions and classes are available to you and what they can do.
EDIT: You can also learn by reverse engineering those scripts (I haven't tested them):
https://steamcommunity.com/sharedfiles/filedetails/?id=3029899210&searchtext=distance+to+asteroid
https://steamcommunity.com/sharedfiles/filedetails/?id=532272288
https://steamcommunity.com/sharedfiles/filedetails/?id=1536579969&searchtext=range+finder
https://steamcommunity.com/sharedfiles/filedetails/?id=823520451&searchtext=range+finder
Visual Studio 2022 since May,,,
There really isnt a way to measure distances in SE unless you have GPS points set. This, IMO, is a huge downfall in SE. This game is getting old and it shows. Now, in the 21st century, there are things call lasers that can measure distances. Under water, it is called sonar. I guess when SE was designed and developed, lasers and sonar were not a thing yet? IMO the devs of SE need to get caught up with real technologies and simulate those in this game. Come on Keen...get caught up to the 21st century :)