Page 1 of 1

LuaRendering: asteroid as orientation_target support

Posted: Sun May 04, 2025 5:26 pm
by Quezler
Asteroid rotation is based on some unit number + tick math which is not exposed as it's orientation towards e.g. luarendering, it would be nice if render objects could be made to rotate along with asteroids.

Re: LuaRendering: asteroid as orientation_target support

Posted: Mon May 05, 2025 1:20 pm
by Genhis
Hello, please describe your use case and proposed API - ideally something which I can copy&paste into the game to test the logic.

Re: LuaRendering: asteroid as orientation_target support

Posted: Mon May 05, 2025 5:54 pm
by Quezler
- new world
- /cheat all
- create a non-nauvis platform
- wait for asteroids to spawn
- run this code

Code: Select all

/c local asteroid = game.player.selected
rendering.draw_sprite{
  sprite = "item/rail",
  target = asteroid,
  surface = asteroid.surface,
  orientation = math.random(),
  oriented_offset = {1, 1},
  orientation_target = asteroid,
  use_target_orientation = true,
}
this would cause the rendered sprite to rotate along with the asteroid's slow rotation speed, this works just fine on vehicles since they actually expose their orientation, but asteroids don't know their orientation until they are rendered.

do consider this low priority, this would just be a convenient way to have them rotate without needing to script an invisible entity on the surface and updating that each tick, i tried to just have a slowly spinning train on a hidden surface but the orientation target can apparently not cross surfaces.