Sample of simple collision detection used in my map!
Collision
Events
Timer - Every 0.03 seconds of Game Time
Local Variables
I = 0 <Integer>
CollisonGroup = (Empty unit group) <Unit Group[6]>
Conditions
Actions
General - For each integer I from 1 to 5 with increment 1, do (Actions)
Actions
Unit Group - Add all units in (Any units in (Region((Position of Missles[I]), 1.0)) owned by player 2 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to CollisonGroup[I]
Unit Group - Pick each unit in CollisonGroup[I] and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Distance between (Position of Missles[I]) and (Position of (Picked unit))) <= 1.0
Then
Unit - Order Missles[I] to (Baneling - Explode) (Replace Existing Orders)
UI - Display "Unit In Range" for (All players) to Chat area
Else
Hey TECGhost, I really wanna use this type of trigger in my map to detect my hero's attack. Its currently shooting a normal fireball as its basic attack which moves slowly toward the enemy, my issue is that once the unit is dead my hero has another 2 fireballs flying into empty space, i figured i could make use of them by adding a collision detection trigger like you have here.
If you don't want to explain the trigger that's fine I'll figure out how it functions with time, but my concern is your "position of Missles[I]" part of the code. How did you obtain that unit-group/form it? There should be more to your trigger...right?
Go to the behaviors tab. Create a new behavior of type "buff". In the options for the behavior, there should be something along the lines of "periodic effects" or "effects periodic". Here, you can add your effect.
Then, go to the effects tab. Make an effect of type "search area" (or search, forgot the exact name). A search effect, when triggered, will check for nearby units in the radius you specify in the area option. You also select an effect which happens to units it finds from searching. If you'd like to the projectile to die when it collides, set the maximum count to 1. Make the radius of the search effect how close you'd like the projectile to be to a unit before it is able to collide with it.
If you have a specific damage effect you've made, you want it to be the effect that's triggered from the search effect. If you want the projectile to die when it collides, you can change the damage effect to be a "set" effect (a set effect is an effect which allows you to specify multiple effects in the set effect, and perform them all at once). In this set effect, include your damage effect, as well as another effect to remove the behavior from the projectile I talked about before.
Now, in the behavior, you want to put the search effect you've made as the periodic effect. There's an option for how long a period takes (how often it tries searching around the unit with the behavior). I believe you can leave it at zero and it should call the search effect every few milliseconds (but I'm not sure, you might have to change it to a number).
Now, in the duration option for the behavior, set it to however long you'd like to missile to travel before dying automatically.
To get the missile to die automatically, you can add an effect that kills the projectile (kill unit) to the "expire" option of the behavior. The expire option allows you to set an effect which is triggered when the behavior's duration runs out.
Earlier, I said to add an effect to the set effect which removes is the behavior when it collides. This is because there is an option for what happens when the behavior is removed prematurely (effect - final). Add an effect to kill the projectile here, as well.
@SexLethal: Go
For 1, the easiest thing you can do is find the actor of type equip with a title similar to "ghostnukeexplode". Change the effect in that actor to your damage effect.
I can't do 2 off the top of my head, but it should involve something similar to 1. Play around with actors.
Sample of simple collision detection used in my map!
Collision
Events
Timer - Every 0.03 seconds of Game Time
Local Variables
I = 0 <Integer>
CollisonGroup = (Empty unit group) <Unit Group[6]>
Conditions
Actions
General - For each integer I from 1 to 5 with increment 1, do (Actions)
Actions
Unit Group - Add all units in (Any units in (Region((Position of Missles[I]), 1.0)) owned by player 2 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to CollisonGroup[I]
Unit Group - Pick each unit in CollisonGroup[I] and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Distance between (Position of Missles[I]) and (Position of (Picked unit))) <= 1.0
Then
Unit - Order Missles[I] to (Baneling - Explode) (Replace Existing Orders)
UI - Display "Unit In Range" for (All players) to Chat area
Else
Rise from the grave, i am in need of assistance.
Hey TECGhost, I really wanna use this type of trigger in my map to detect my hero's attack. Its currently shooting a normal fireball as its basic attack which moves slowly toward the enemy, my issue is that once the unit is dead my hero has another 2 fireballs flying into empty space, i figured i could make use of them by adding a collision detection trigger like you have here.
If you don't want to explain the trigger that's fine I'll figure out how it functions with time, but my concern is your "position of Missles[I]" part of the code. How did you obtain that unit-group/form it? There should be more to your trigger...right?
Thanks for the help
@ViG01: Go
You may find it simpler to add a behavior to the unit that has a periodic search effect, which, upon finding a unit, does some effect.
It doesn't require any triggers.
EDIT: Add the behavior to the missile.
Hi Vexal, thanks for the reply!
So i was looking through the behavior tab, and realized I don't know how to make a behavior with a periodic search effect. Could you elaborate please?
Hoping it isn't terribly complicated, ill keep searching around and trying things out. Thanks.
@ViG01: Go
Go to the behaviors tab. Create a new behavior of type "buff". In the options for the behavior, there should be something along the lines of "periodic effects" or "effects periodic". Here, you can add your effect.
Then, go to the effects tab. Make an effect of type "search area" (or search, forgot the exact name). A search effect, when triggered, will check for nearby units in the radius you specify in the area option. You also select an effect which happens to units it finds from searching. If you'd like to the projectile to die when it collides, set the maximum count to 1. Make the radius of the search effect how close you'd like the projectile to be to a unit before it is able to collide with it.
If you have a specific damage effect you've made, you want it to be the effect that's triggered from the search effect. If you want the projectile to die when it collides, you can change the damage effect to be a "set" effect (a set effect is an effect which allows you to specify multiple effects in the set effect, and perform them all at once). In this set effect, include your damage effect, as well as another effect to remove the behavior from the projectile I talked about before.
Now, in the behavior, you want to put the search effect you've made as the periodic effect. There's an option for how long a period takes (how often it tries searching around the unit with the behavior). I believe you can leave it at zero and it should call the search effect every few milliseconds (but I'm not sure, you might have to change it to a number).
Now, in the duration option for the behavior, set it to however long you'd like to missile to travel before dying automatically.
To get the missile to die automatically, you can add an effect that kills the projectile (kill unit) to the "expire" option of the behavior. The expire option allows you to set an effect which is triggered when the behavior's duration runs out.
Earlier, I said to add an effect to the set effect which removes is the behavior when it collides. This is because there is an option for what happens when the behavior is removed prematurely (effect - final). Add an effect to kill the projectile here, as well.
@Vexal: Go
How do you make the projectile
1. Show an explosion effect on collision
2. Show a lasting wound effect on the unit hit
@SexLethal: Go For 1, the easiest thing you can do is find the actor of type equip with a title similar to "ghostnukeexplode". Change the effect in that actor to your damage effect.
I can't do 2 off the top of my head, but it should involve something similar to 1. Play around with actors.
(Edited cauuuussseeeee' i figured it out, works now. Thanks Vexal!)