Issues with projectile orientation

Place to get help with not working mods / modding interface.
Post Reply
twu
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Apr 23, 2021 11:26 pm
Contact:

Issues with projectile orientation

Post by twu »

I had this idea in my head to create a weapon that would shoot trains. I ended up getting ahead of myself and worked on the code first, thinking the actual animation would be simple. However, it took me quite a while to realize that since the train is a 3d object I can't simply just rotate it like with the 2d bullets. Is there a way to find the angle at which the player is shooting to orient the train correctly? I've also considered creating a custom entity just to render a train over the actual projectile, but I'm not really sure how to do that and if it's worth the effort.

Trific
Fast Inserter
Fast Inserter
Posts: 122
Joined: Thu Dec 31, 2020 7:57 pm
Contact:

Re: Issues with projectile orientation

Post by Trific »

Oooooh... now I get it.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3465
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Issues with projectile orientation

Post by DaveMcW »

on_script_trigger_effect is the standard event for detecting projectile launches, but this does not provide any target information that you could use to calculate angle.

You could make the weapon a capsule and use on_player_used_capsule, which does provide the target position. Then use surface.create_entity{} to create a proper projectile.

Note that all of this must be done in control.lua, which operates rather differently than data.lua.

Post Reply

Return to “Modding help”