Page 1 of 1
Creating a better targeting system for starfighter-blasters
Posted: Fri Dec 22, 2017 3:54 pm
by mrcluster
Hello, I've been thinking about adding in a way of using starfighter-blasters that's much easier to use and way closer to how it is in-universe; what I mean is, I want to make starfighter blasters lock onto targets and fire in the direction of the locked-onto-fighter. This would allow people to make gunning-runs without having to point their fighter straight towards whatever they want to shoot, which can be suicidal if done on infantry. Is there any way to do this? My main problem is finding a way to offset the laser's firing direction based on where the targeting reticle is facing.
Re: Creating a better targeting system for starfighter-blast
Posted: Sat Dec 23, 2017 2:39 pm
by Samee3
The best I've been able to come up with is a sort of missile launcher with auto-lock, where the ordnance (a missile) has a minimum speed of 0 and then accelerates to a laser-like speed (say, 2000m/s) in a very short time (say, 0.1s). The missile has a turn rate that will allow it to change direction whilst accelerating, but will be negligible at velocity. I moved on to another mod before I found the motivation to polish it up and make it look more convincing.
Re: Creating a better targeting system for starfighter-blast
Posted: Sun Dec 24, 2017 12:29 am
by mrcluster
Samee3 wrote:The best I've been able to come up with is a sort of missile launcher with auto-lock, where the ordnance (a missile) has a minimum speed of 0 and then accelerates to a laser-like speed (say, 2000m/s) in a very short time (say, 0.1s). The missile has a turn rate that will allow it to change direction whilst accelerating, but will be negligible at velocity. I moved on to another mod before I found the motivation to polish it up and make it look more convincing.
The other idea I had was to offset the laser's direction in the same way the Wookiee Bowcaster does, then use Lua's SetProperty to change that ODF parameter based on what the currently locked-on target's position would be. However, I don't know of any way to hook into the event of a laser firing, especially early enough that I can change the direction it fires in.
Re: Creating a better targeting system for starfighter-blast
Posted: Sun Dec 24, 2017 6:31 pm
by Samee3
List of LUA functions
It sounds like it would be a matter of getting the position/rotation of both the target and the weapon, and calculating an offset from that.
I've been relatively satisfied with the way
my targeting system turned out, but I'm curious if you can come up with anything.
Re: Creating a better targeting system for starfighter-blast
Posted: Sun Dec 24, 2017 7:44 pm
by mrcluster
Samee3 wrote:List of LUA functions
It sounds like it would be a matter of getting the position/rotation of both the target and the weapon, and calculating an offset from that.
I've been relatively satisfied with the way
my targeting system turned out, but I'm curious if you can come up with anything.
One thing I did notice was that, to keep the blasters centred, starfighters like the A-Wing will slightly point their cannons inward as you get closer to a target/the ground. As well, AI can actually fire their blasters in different directions while flying. So, the code for switching the direction the blasters are facing exists. The problem is accessing it.
Edit: GetWorldPosition(unit) is apparently a thing. Anyone know about doing stuff when lasers are fired/getting the locked-on target of a unit?
Edit2: Oh wait, goddamn! I could use an ObjectCreate callback in Lua; that way I can hook into the creation of a blaster bolt! Hell yeah, I might get somewhere now.