Page 1 of 1

Issues with projectile orientation

Posted: Fri Apr 23, 2021 11:31 pm
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.

Re: Issues with projectile orientation

Posted: Sat Apr 24, 2021 12:32 am
by Trific
Oooooh... now I get it.

Re: Issues with projectile orientation

Posted: Sat Apr 24, 2021 1:30 am
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.