I am hoping someone can give me an outline on how to do the following:
I have a movement system for moving my car around. I want to make it so that when the player holds down the "Q" key, the car fires forward machine guns. These guns fire instantly, and hit the first target in a straight line away from the car.
I've broken it into 3 parts I think:
1: Detect firing. I was planning on just having a dummy button for "Q" and detecting the pressing of the key manually. Is that a good idea?
2: Find target. This I'm not sure about. The only thing I could think of would be a "While Loop" that updates a "distance" variable and goes distance + 1 from car and looks for enemies in a range around that point, then distance + 2, then distance +3, until it reaches max distance or finds a target enemy. But that seems very very computationally expensive.
3: Damage target. I assume the easiest thing would be a to put some special effect on the target and do damage via the same trigger that finds the target.
If anyone can help with any of these steps, please let me know. Also, if you can think of more efficient ways to do this, that would be great.
p.s. One thing I thought of that seemed impractical would be to have a weapon that does damage in a line (like the flamethrower as I recall) and have the car attack an invisible unit that is moved in front of it at all times. But that seemed very odd and hard to work with.
I have a movement system for moving my car around. I want to make it so that when the player holds down the "Q" key, the car fires forward machine guns. These guns fire instantly, and hit the first target in a straight line away from the car.
I've broken it into 3 parts I think:
1: Detect firing. I was planning on just having a dummy button for "Q" and detecting the pressing of the key manually. Is that a good idea?
2: Find target. This I'm not sure about. The only thing I could think of would be a "While Loop" that updates a "distance" variable and goes distance + 1 from car and looks for enemies in a range around that point, then distance + 2, then distance +3, until it reaches max distance or finds a target enemy. But that seems very very computationally expensive.
3: Damage target. I assume the easiest thing would be a to put some special effect on the target and do damage via the same trigger that finds the target.
If anyone can help with any of these steps, please let me know. Also, if you can think of more efficient ways to do this, that would be great.
p.s. One thing I thought of that seemed impractical would be to have a weapon that does damage in a line (like the flamethrower as I recall) and have the car attack an invisible unit that is moved in front of it at all times. But that seemed very odd and hard to work with.