How to make a realistic weapon/gun that shot a bullet that hit the first target it touches?
Progress:
I have added a behavior to the ammo unit and set that behavior to as fast as possible but around 0.05 seams to be the fastest it can update. At each period i added a search area effect on 0.1 radius. The problem is that it dont search often enough become of the limitation on the behavior.
So what i have done is that i changed the search area effect to a create persistent effect and then have that persistant do what the behavior could not do.
The persistant do search area effect towards the bullets goal in a more rapid pace then the behavior could.
This does work with some trail and error testing with setting the correct time period so the persistants are created under the bullet.
BUT now i have hit a major roadblock that i'm not sure how to fix.
How can i set the offset angle of the next search area the persistent make. I want it to be the bullet facing, How do i do that?
The behavior seams to be ok and working perfect HOWEVER the missile unit seam to be teleporting forward. i added a persistant on the unit that executed a effect in a very fast pace and then i linked a model animation to each effect and the result was clear, the ammo unit was jumping forward 5 yards each time. Ok now i know what to do and the exact timing for it but i still dont know how to fix the offset :D
You mean the missile is jumping forward instead of going straight? And that it's not facing the target? Also seems like it's not searching often enough.
So you made an ammo unit to a launch missile effect. Now make an actor for it that is created when the ammo unit is created.
Add the behavior to the ammo unit like you have and make it have a periodic persistent effect, with the search effect. Now it should search often enough to find any units it hits.
Do you have the ground mover for the missile? Give it a new mover that never checks if it has reached the target, so that it keeps going forever.
Not sure i understand you perfectly, care to make a sample map of that? Just make a target ability that launch the marauder missile and set the mover speed to 40.
Add the behavior to the ammo unit like you have and make it have a periodic persistent effect, with the search effect. Now it should search often enough to find any units it hits.
I did this already on the actor for the ammo unit.
I dont know why the persistent make the offset going the wrong way behind the unit :(
Now i can't get it to work.. But maybe look at this test map i made a while back. I tried to recreate it but there were a few thing that just didn't want to.
Not sure i understand you perfectly, care to make a sample map of that? Just make a target ability that launch the marauder missile and set the mover speed to 40.
I did this already on the actor for the ammo unit.
I dont know why the persistent make the offset going the wrong way behind the unit :(
Mover speed of 40 can be too fast for projetiles like this, the chance of them traveling through targets (because the distance they fly during the shortest interval (0.0625s) is larger than the radius/diameter of many units) is really high if you set the mover speed too high. I'm not 100% sure which speeds are still okay and which are not, also depends on the smallest unit radius you are using. But 40 is definitely somewhere on the edge and will probably cause problems in some cases.
That said, there are many different ways to create projectiles like that. Behaviors are one way, but as far as I know they have some problems of recognizing the caster as the killing unit and setting the kill counter etc. (never tried it myself though, so don't 100% know if that is true). Another way is described in Kuekens Colliding Projectiles Tutorial which is very educational.
If you dont need a protectile you could even remove that entirely. Create a search on the attacker with a narrow angle (lets say 5) then search for a single target and set Target Sorts to Distance From Caster or something like that. This way the search will pick the nearest target so you apply the "impact" effect to it.
I have been thinking about this option to, its far from perfect because its a homing bullet and the area can get wide at long range.
However, wanna give it a try but not sure how to make it.
How to make a unit face that point? what effect should i do? I need the unit to face the point and then make the search area effect else it will search in whats in front of him atm witch is not the target point.
Hmm this could work but i badly need the get the search angle to work, dont know at all how to make that happen :/
So here is my thoughts.
First i create a persistent with the ability. The persistent will then know where the target point is and where it are it self. Next i need to make a search area at the same location as the persistent and with the facing of the target point and this is where i fail. I'm only able to make the search area search for units directly below it (-Y). How do i turn the damn search area in the right direction??
Apparently is the search area for the data editor broken when it come to the direction of the arc. SO i have 2 option, play around with the persistants or trigger it.
@Sherlia: Go What happened? You need to create the search on the attacker. So the arc is automatically correct because the attacker is facing the target, unless the weapon allows it to attack in any direction.
@Sherlia: Go What happened? You need to create the search on the attacker. So the arc is automatically correct because the attacker is facing the target, unless the weapon allows it to attack in any direction.
And thats exactly what the weapon can, attack in any direction. And its not a weapon attack its an ability because weapons cant target ground.
Ok how about this.
Ability Create a persistant that set a periodic offset of 20 from caster towards target point
The periodic use 1 effect, launch missile. towards the new target point
Missile has behavior that create a Persistant at missile spawn point.
The new Persistant does small periodic search area effect with offsets on 0,2 distance towards the "new target with a 20 offset".
If search radius find a target then it damage the target and destroy the missile(caster).
The above method works but i have hit a major road block and that how each effect refer to each other.
The second Persistent i make, how can i refer to the "offset end" if i want it to refer to the point with 20 offset from persistent?
If i tell it to go with the missile direction then it will always go straight down becouse that the default missile facing angle before it turn to target.
Ok you need to make sure its a mover that allow the ammo unit to keep moving. You will probably need to make this from scratch.
Then you put a behavior with a search area effect. If it finds an enemy unit then you do a set with 2 damage effects. One that kills the ammo unit (make sure the ammo unit's invulnerable flag is off) and the other that deals damage to the target unit.
Ok so i just used the trigger event "Unit enters range of unit" with action to kill triggering unit and the unit in range was a preplaced vulture with a high movement speed. I placed a long line of zerglings and set collide of vulture to none, so it just past through them. The range was set to 1.
Movement speed set to 30: Kills all zerglings
Movement speed set to 35: Leaves zerglings at some places alive, even after running over them multiple times.
Movement speed set to 40: Leaves many zerglings alive
I appears that enter region events also works using periods, checking at small invervalls of time. But if it's too fast, it can't keep up. Is this an ability for a single unit? I would place the missiles you need and then move them with triggers. Actually that's teh same as launch missile with search behavior, but maybe it has a lower period?
Ability create a persistent that set target point 20 away from caster towards where you clicked (point). This will make the missile always move 20 in distance regardless on how close you click to unit. This persistent then launch the missile.
The missile unit has a behavior initial that create a persistent.
The new persistent have 4 periods with an offset on 0, 5, 10 and 15. Each effect are executed with 0.125 seconds interval. (4*0.125 = 0.5. 40*0.5 = 20, the distance the bullet travel.) The periods always check if caster is still alive (the bullet) Each period create a new pesrsistent.
The new persistents has 25 periods with 0.005 interval. Each period has an offset on +0.2 away from the persiostent. 25*0.2 = 5. 0.005*25 = 0.125. The period effect is a search area on 0.1 radius. The periods always check if caster is still alive (the bullet). If the search area find a target then they damage it and kill the bullet hence stopping everything :) 0.005 is a kinda fast persistent, i dont know how fast its possible to do but that + the 0.125 period is the ones who decide how fast the persistent should travel, the bullet in it self does nothing and are just for show. This make a PERFECT hit on impact bullet traveling at 40 distance/sec. It never pass trough zerglings or hit anything but just 1 unit on its path.
Well something like that, i have now made a shotgun, pistol and a AK4 that works perfect with this method. Very high precision.
Can you comment on the performance? Seeing that your method creates a large number of searches, does it make the game lag if there's like 10 different players and they're all firing with an AK or a shotgun at the same time? So for example say each player fired 10 bullets so you have 100 bullets flying around at the same time so we got 100 persistent effects moving with the bullets each of which is periodically creating its own search effect. Say that's all on the player's screen, so he's seeing the other players plus 100 bullets at the same time.
Can you please test this and comment on the performance? I'm very interested in a realistic weapon's system.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
How to make a realistic weapon/gun that shot a bullet that hit the first target it touches?
Progress:
I have added a behavior to the ammo unit and set that behavior to as fast as possible but around 0.05 seams to be the fastest it can update. At each period i added a search area effect on 0.1 radius. The problem is that it dont search often enough become of the limitation on the behavior.
So what i have done is that i changed the search area effect to a create persistent effect and then have that persistant do what the behavior could not do.
The persistant do search area effect towards the bullets goal in a more rapid pace then the behavior could.
This does work with some trail and error testing with setting the correct time period so the persistants are created under the bullet.
BUT now i have hit a major roadblock that i'm not sure how to fix.
How can i set the offset angle of the next search area the persistent make. I want it to be the bullet facing, How do i do that?
The behavior seams to be ok and working perfect HOWEVER the missile unit seam to be teleporting forward. i added a persistant on the unit that executed a effect in a very fast pace and then i linked a model animation to each effect and the result was clear, the ammo unit was jumping forward 5 yards each time. Ok now i know what to do and the exact timing for it but i still dont know how to fix the offset :D
You mean the missile is jumping forward instead of going straight? And that it's not facing the target? Also seems like it's not searching often enough.
So you made an ammo unit to a launch missile effect. Now make an actor for it that is created when the ammo unit is created.
Add the behavior to the ammo unit like you have and make it have a periodic persistent effect, with the search effect. Now it should search often enough to find any units it hits.
Do you have the ground mover for the missile? Give it a new mover that never checks if it has reached the target, so that it keeps going forever.
@LaxSalmon: Go
Not sure i understand you perfectly, care to make a sample map of that? Just make a target ability that launch the marauder missile and set the mover speed to 40.
I did this already on the actor for the ammo unit.
I dont know why the persistent make the offset going the wrong way behind the unit :(
@Sherlia: Go
Now i can't get it to work.. But maybe look at this test map i made a while back. I tried to recreate it but there were a few thing that just didn't want to.
Mover speed of 40 can be too fast for projetiles like this, the chance of them traveling through targets (because the distance they fly during the shortest interval (0.0625s) is larger than the radius/diameter of many units) is really high if you set the mover speed too high. I'm not 100% sure which speeds are still okay and which are not, also depends on the smallest unit radius you are using. But 40 is definitely somewhere on the edge and will probably cause problems in some cases.
That said, there are many different ways to create projectiles like that. Behaviors are one way, but as far as I know they have some problems of recognizing the caster as the killing unit and setting the kill counter etc. (never tried it myself though, so don't 100% know if that is true). Another way is described in Kuekens Colliding Projectiles Tutorial which is very educational.
If you dont need a protectile you could even remove that entirely. Create a search on the attacker with a narrow angle (lets say 5) then search for a single target and set Target Sorts to Distance From Caster or something like that. This way the search will pick the nearest target so you apply the "impact" effect to it.
@SoulFilcher: Go
I have been thinking about this option to, its far from perfect because its a homing bullet and the area can get wide at long range.
However, wanna give it a try but not sure how to make it.
How to make a unit face that point? what effect should i do? I need the unit to face the point and then make the search area effect else it will search in whats in front of him atm witch is not the target point.
Hmm this could work but i badly need the get the search angle to work, dont know at all how to make that happen :/
So here is my thoughts.
First i create a persistent with the ability. The persistent will then know where the target point is and where it are it self. Next i need to make a search area at the same location as the persistent and with the facing of the target point and this is where i fail. I'm only able to make the search area search for units directly below it (-Y). How do i turn the damn search area in the right direction??
Apparently is the search area for the data editor broken when it come to the direction of the arc. SO i have 2 option, play around with the persistants or trigger it.
@Sherlia: Go What happened? You need to create the search on the attacker. So the arc is automatically correct because the attacker is facing the target, unless the weapon allows it to attack in any direction.
And thats exactly what the weapon can, attack in any direction. And its not a weapon attack its an ability because weapons cant target ground.
Ok how about this.
Ability Create a persistant that set a periodic offset of 20 from caster towards target point
The periodic use 1 effect, launch missile. towards the new target point
Missile has behavior that create a Persistant at missile spawn point.
The new Persistant does small periodic search area effect with offsets on 0,2 distance towards the "new target with a 20 offset".
If search radius find a target then it damage the target and destroy the missile(caster).
The above method works but i have hit a major road block and that how each effect refer to each other.
The second Persistent i make, how can i refer to the "offset end" if i want it to refer to the point with 20 offset from persistent?
If i tell it to go with the missile direction then it will always go straight down becouse that the default missile facing angle before it turn to target.
Ok you need to make sure its a mover that allow the ammo unit to keep moving. You will probably need to make this from scratch.
Then you put a behavior with a search area effect. If it finds an enemy unit then you do a set with 2 damage effects. One that kills the ammo unit (make sure the ammo unit's invulnerable flag is off) and the other that deals damage to the target unit.
@FockeWulf: Go Thats was his first choice but the ammo moved too fast for the search periods.
@Sherlia: Go
Ok so i just used the trigger event "Unit enters range of unit" with action to kill triggering unit and the unit in range was a preplaced vulture with a high movement speed. I placed a long line of zerglings and set collide of vulture to none, so it just past through them. The range was set to 1.
Movement speed set to 30: Kills all zerglings
Movement speed set to 35: Leaves zerglings at some places alive, even after running over them multiple times.
Movement speed set to 40: Leaves many zerglings alive
I appears that enter region events also works using periods, checking at small invervalls of time. But if it's too fast, it can't keep up. Is this an ability for a single unit? I would place the missiles you need and then move them with triggers. Actually that's teh same as launch missile with search behavior, but maybe it has a lower period?
I made it work :)
Thanks for all tips but the solution was never with a behavior
Any tips on how you made it work?
I would be very interested in a projectile collision system that works for very fast missiles (with Mover Speed > 40).
@Bommes: Go
Ok i will try my best now :)
Ability create a persistent that set target point 20 away from caster towards where you clicked (point). This will make the missile always move 20 in distance regardless on how close you click to unit. This persistent then launch the missile.
The missile unit has a behavior initial that create a persistent.
The new persistent have 4 periods with an offset on 0, 5, 10 and 15. Each effect are executed with 0.125 seconds interval. (4*0.125 = 0.5. 40*0.5 = 20, the distance the bullet travel.) The periods always check if caster is still alive (the bullet) Each period create a new pesrsistent.
The new persistents has 25 periods with 0.005 interval. Each period has an offset on +0.2 away from the persiostent. 25*0.2 = 5. 0.005*25 = 0.125. The period effect is a search area on 0.1 radius. The periods always check if caster is still alive (the bullet). If the search area find a target then they damage it and kill the bullet hence stopping everything :) 0.005 is a kinda fast persistent, i dont know how fast its possible to do but that + the 0.125 period is the ones who decide how fast the persistent should travel, the bullet in it self does nothing and are just for show. This make a PERFECT hit on impact bullet traveling at 40 distance/sec. It never pass trough zerglings or hit anything but just 1 unit on its path.
Well something like that, i have now made a shotgun, pistol and a AK4 that works perfect with this method. Very high precision.
@Sherlia: Go
Can you comment on the performance? Seeing that your method creates a large number of searches, does it make the game lag if there's like 10 different players and they're all firing with an AK or a shotgun at the same time? So for example say each player fired 10 bullets so you have 100 bullets flying around at the same time so we got 100 persistent effects moving with the bullets each of which is periodically creating its own search effect. Say that's all on the player's screen, so he's seeing the other players plus 100 bullets at the same time.
Can you please test this and comment on the performance? I'm very interested in a realistic weapon's system.