I currently have a movement system I very much like. But, the problem is it came with a traceline system I could not get to work no matter how many maps I tried it in or what units I was using.
I then looked up another traceline tutorial that used a custom script filled with syntax errors.
I looked up some youtube videos that said you can just oder your unit to start attacking in the direction they are facing, but I can't figure out how.
All I am asking for is a step by step guide on how to make my unit launch an attack in the direction I am looking. And yes, I have spent multiple hours looking for one and couldn't find one.
I'll give you the general guideline of how to make a 3D traceline. I made a 12-player 3D Traceline function about a year ago with very simple commands (a single trigger that calculated 12 different tracelines per game loop). I'll explain each section BELOW the trigger. It is expected that you have a good conceptual understanding of trigonometry.
Event: Every 0.0625 seconds of game time.
Conditions: None
Global Variables: TraceUnit (unit) = No Unit.
Local Variables:
Theta (real) = current camera Yaw of player
Phi (real) = -1 * Current camera Pitch of Player
X (real) = [Maximum range of gun]
u (real) = X * Cosine(Phi)
v (real) = X * Sin (Phi)
N (integer) = Number of Checks per loop
p (point) = position of player's unit
r (real) = Radius of Check Circle
temp reg (region) = No region
z (integer) = 0
UG (unit group) = [empty unit group]
h (real) = 0
c (integer) = 0
UnitFound (boolean) = false
Actions:
----------Pick Each Integer from 1 to N and do the following:
If UnitFound = false
then do the following chain of actions:
Set z = picked integer
Set temp reg = Circular Region with radius r at Point P with polar offset z * (u / N) at angle THETA.
Set UG = All units in Temp Reg.
Set h = z * (v / N)
-----------------Pick Each Unit in UG and do the following (this is within the integer loop itself)
---If/Then/Else (within the UG loop that is still within the integer loop).
If Height of the Picked Unit > h - r
If Height of the Picked Unit < h + r
Then set TraceUnit = Picked Unit.
Then set UnitFound=True
Break Loop Unit Group Loop.
Else - Do nothing
If Unit Found = false
Then set c = z
else do nothing
------------
Else
Break Integer Loop:
If c < N
then Do nothing
else Set Traceunit = No Unit.
This post will explain the individual use of each variable and the concept of the traceline. This post also explains the basic mathematical operations and usages of sine and cosine. The post after this one contains detailed guide on how to put them all together.
The Traceunit variable is [unit] type variable. It is the global variable that the traceline itself is meant to evaluate. The reason we make it a global variable is so we can communicate the detected Traceline target to other in-game triggers.
Theta is a [real] variable. Theta tells us the direction (like north, south, east or west) that the camera for our player is facing. We get this value by setting it equal to the current camera Yaw of our Player.
Phi is a [real] variable. Phi tells us the inclination of the players camera. For instance is he looking 45 degrees above the horizon his pitch would be NEGATIVE 45. In Starcraft 2 and most computer applications POSITIVE PITCH is below the horizon and NEGATIVE PITCH is above the horizon. In more advanced calculations involving quaternions this system is preferable. However for something simple like a traceline this really f***s with the mind, so we'll set Phi equal to -1 x Current Camera Pitch of Player.
X is a [real] variable. It is simply the range of the weapon, or more technically the length of the traceline.
u is a [real] variable. This variable is the Horizontal range of your weapon. If your camera inclination equals zero (looking at the horizon), then u is equal to X. However, suppose your were looking straight up at the sky. Your weapon is going to shoot targets on the horizon if you are looking at the top of the sky! In fact the when you're looking straight up, the horizontal range of your weapon is ZERO. So how do we calculate the horizontal range of your weapon at any camera inclination (other than 0 degrees and 90 degrees). Well those good old days of Junior High School Trig should show us the way!
The range of your weapon is in fact always the same (X) as you increase your camera inclination. The trajectory of your weapon forms a RIGHT TRIANGLE with the ground. The angle between the adjacent leg (ground/horizontal leg) and the hypotenuse is equal to the inclination of the Player Camera, in other words Phi. So in order to calculate the length of the horizontal leg we multiply X by Cosine(Phi). Remember adjacent/hypotenuse = cosine(PHI), so we can cross multiply to get X * (cosine Phi) = u. Thus u = x * (cosine Phi).
v is a [real] variable. This variable complements u. It calculates the maximum height that your weapon will shoot at. If your pointing at the horizon, your weapon won't shoot very high, but if you're looking straight up, your weapon will shoot very high into the air! In this case we are trying to calculate the opposite leg of the right triangle. Opposite/Hypotenuse = sin(Phi) such that v = X * sin(Phi).
N is an [integer] variable. This is an interesting number that controls the accuracy of the traceline. This will control how often we check for the presence of a unit in your line of fire, starting from the position of the player and ending at end of the trajectory of your gun. Basically it takes the length of the trajectory and cuts it into N equal pieces.
Imagine that we put a tick mark (like on a ruler) at each of these points that we "cut" the trajectory line. We are going to create a circular region at each of these points and check to see if there's a unit inside of them. We will start at the first tick mark located next to the player's controlled unit. If we don't find a unit in this circle we move on to the next tick mark and see if there's a unit located in that region. If not, we move on again until we find a unit within a circle around one of the tick marks. If we never find a unit at the end of the trajectory (the circle around the last tick mark) it means that their is no unit in the line of fire.
Ok so how do we do this? Read on!
temp region is a [region] variable. This variable will be used as the circular region that we are temporarily checking for units around a specific tick mark.
r is a [real] variable. This determines the radius of the circle Temp region. We want the circles from one tick mark to the next to overlap for accuracy. So if X is divided into N segments, by setting the radius of each circle to X/N we ensure the the edge of each circle makes contact with the center of the previous circle.
z is an [integer] variable. z will be used to keep track of which Tick Mark we are at.
UG is a [unit group] variable. This variable will be set to the collection of units inside our temp region while checking a specific tick mark.
h is a [real] variable. h determines the height of a tick mark along the trajectory (relative to the ground). If we're shooting at a target in the air, we need to make sure that when we detect a unit in the circular region, that the unit isn't too high or too far below the trajectory line in 3D space. In actuality, when we create circular regions on the ground, we are actually creating 3D cylinders with an infinite height. Thus we need to ignore units that are above or below the trajectory height at the specific Tick Mark we are checking.
To do this we need to calculate the height of the tick mark itself. Thankfully we can use the fact that similar triangles are proportional to each other. We know that X has been cut into N parts, so the height difference between each tick mark is v/N. Thus the height at any particular tick mark (z) is equal to z * (v/N). So h = z * (v/N).
UnitFound is a [boolean] variable. Boolean variables are either True or False. If a unit is found in any of the Checks, we want to set this variable equal to True. This will allow us to STOP the trigger so that it doesn't continue. Once a unit is found, we don't want it to find more units!
c is an [integer] variable. This variable is used if NO UNITS ARE FOUND at the END of the trigger. Basically if c = N at the end of the trigger, then no units were found. In that case we set TraceUnit = No Unit (default. value). Another way of looking at it c is that it records how many failed attempts occurred. After N failed attempts we know there is no unit in the traceline.
Now let's actually make the trigger. So we're going to start with an integer loop. This will be from 1 to N. This is because we are cutting X into N parts and we need to check at each of the N tick marks.
Once the Integer loop is setup, selection the action "If Then Else." Put the following condition in the IF statement "If UnitFound = false." We do this to make sure that we haven't found a unit at any of the previous tick marks.
Now we're going to put an action in the ELSE (not the THEN) part. Put the action "Break." We do this to make sure that if a unit is found at a previous tick mark, that the trigger itself stops searching for more units.
Now go back to the THEN. Everything that we are going to do from here is contained with this THEN. Set z to the picked integer. This keeps track of which tick mark we are checking for units.
Now we need to create a circular region at our tick mark. To do that we need the horizontal distance of our tick mark from the position of the player's camera. So Knowing that we cut X into N parts, then we also cut "u" into N parts (u is the length of the horizontal leg of the triangle). That means each tick mark is a distance of u/N apart, such that the total distance of a specific tick mark from the player's camera is given by z * (u/N).
Now set the region variable "temp reg" equal to Circle with radius "r" at point "p" with polar offset by (z *(u/N)) at angle THETA (facing of the player's camera).
Now set UG equal to all units inside of temp reg. This gives us a collection of units in the region.
Now we're going to check the heights of each unit in this region to ensure they aren't too far above or below our trajectory line. So set h equal to the height of the tick mark from the ground. This is given by z * (v/N). So h = z*(v/N).
Select the "Pick every unit in unit group" action and select UG as the unit group.
Now under that Pick Every Unit action put an "If then Else" and put the two conditions:
If height of Picked Unit is less than h + r
If height of Picked Unit is greater than h - r
We use +/- r in this conditions in order to give us some "breathing room" because the chances of a unit being having the EXACT height of h are practically zero (a unit with height 13.98 wouldn't' be detected if h was 14, so we need the +/- r to give us a more realistic effect).
In the Then command put
Set TraceUnit = Picked Unit
Set UnitFound = True
Break (this stops the traceline from trying to find more units after it found a unit).
In the else command put NOTHING (leave it blank).
Now create a new action outside the Pick Every Unit action (but still within the integer loop) and select IF THEN ELSE and make the condition If UnitFound= false, then set c = z and leave the ELSE command blank again.
Now finally create a new action OUTSIDE the integer loop and add the following IF THEN ELSE
If c < n
Then (leave blank)
Else Set TraceUnit = No unit.
This last part ensures that if no unit is found along the trajectory that our gun doesn't shoot at a random unit. For instance say you were shooting a unit, but turned your camera 90 degrees to the right and started to shoot at nothing, since no new unit was found in the traceline, your gun would accidentally continue shooting at the target 90 degrees to your left since the TraceUnit target wasn't reset to No Unit!
Also, you may notice there are two breaks in this trigger that activate when a unit is found. The first break is in the Pick Every Unit series of actions. This fires to stop the game from checking other units in the unit group. The game then goes back to the top of the trigger and starts at the next value of z in the integer loop. However the condition UnitFound is now equal to true, so it skips to the ELSE part that says "Break." This second Break stops the integer loop, which in turn prevents it from returning to the Pick Every Unit loop.
If a unit is found before the final integer loop completes, then c will always be less than N and therefore the set TraceUNit = no Unit has no way of ever being fired by accident if a unit is found.
to be honest ur traceline is very cp heavy due to it being a looping trigger with a bunch of calculations. You should instead be using for every mouse clicked event to start it off. No reason to have a looping traaceline. It has too many vaariables and theirs a much simpler triggering format to get the same and even better effect.
I would start off by looking at the TPS engine in the trigger library. That is where I started my traceline. Try to understand that first before you go make your very own traceline. My current traceline from StrikeCraft currently includes many variables. Detects any ground height, detects if theres a ground height in front of you so you can't shoot across it, 3d projectile collosion in space, accuarcy which gives some randomness, recoil, range. Then on top of that creating a system for the weapons themselves such as zoom amount, bullets per shot, attack speed, max spread on crosshairs, aim amount, ammo, max spread while hip firing, ammo tracking for items dropped, auto pick up system. I had to figure an effective and easy way to create a cover system that didn't require too many variables and messy if then statements. Inorder to that point I had to go thur tons of traceline experiments and tons of reorganizing and trashing of older systems. This is complex stuff. If you want to go the full 9 yards your also gunna have to worry about making a traceline for grenades with the bounce effect.
Now dont' be scared.
There are couple shortcuts/complex ways of making a traceline. If you don't want a complex traceline that doesn't include the accuarcy x and y with the dynamic moving crosshairs. I'd recommend do this with trigger and data based. For example, order the unit to attack the unit when the traceline finds a unit. Then the data has validators which stop the unit from attacking so you only attack him once. This is a more easier approach where you can just change a few numbers in the data and ur good to go. Have the weapons as items but have them equip the weapon if they carry them so their weapon changes with it therefore the effect of the attack aswell. But the problem here is that its messy when it comes to 3d projectile and having effects and explosives to hit the ground if you miss due to the fact that you have to create another system that focuses on that.
If you want a complex traceline like mine. I use effects at point and unit to create those explosions at the ground and air. Your going to need algorthirms. I use the data only for making effects, actors and items. But again its pretty tough to make a true replica fps system from an rts system. I too am still working out the kinks but its pretty dam close atm. I do accuarcy a bit differently then the post above. I try to replicate a real life traceline so there would be an X accuarcy in degrees which will force the traceline in a random degree starting direction. Then I have a random real which adds to my comparing condition. The Y is related to the crosshair and so is the X, so all I need to change is the crosshair and it also changes the X and Y. So less mess and work.
Overall, if you want to make a traceline try to make it with the minimal amount of variables needed and try not to make it too complex then it needs to be. Reason why I tend to build the system really messy and over time I trim the fat off it and get it really clean. unless you plan to make this single player but in my case I plan to have this traceline run for 14 players so I can't have that amount of freedom.
Start with the TPS library traceline, thats where I learned how to make a good traceline. That traceline isn't the best but it will do for now. Some things you'd like to know is that it seraches like from 1 to 100 so there are 100 circles with a fixed radius that seraches units in a line with the direction of the camera from the player's unit. That is the most important thing about that traceline. Then when it finds a target it compares its custom value which is what the creator sets that units height as. Using this he compares it with the function of the angle of tangent with the camera to determine if its within range. if it is its a hit and set the target as that unit.
Basically, its a line which seraches for dots. In an rts stand point, its easier to make a game with dots instead of rag dolls. The rts system places models for these dots which is what you see. But looking inside the game itself, they are all basically flats dots on a flat 2d plane with a radius.
If you still need help we can talk on skype/vent just pm me
That is actually the first one I was talking about. Even after extended discussion with the creator, no map I tried that traceline in would work no matter what combination of units I attempted. I even uninstalled and reinstalled my entire editor in the possibility it might be a glitched editor and still could not get the traceline to work at all.
to be honest ur traceline is very cp heavy due to it being a looping trigger with a bunch of calculations. You should instead be using for every mouse clicked event to start it off. No reason to have a looping traaceline. It has too many vaariables and theirs a much simpler triggering format to get the same and even better effect.
XXXXXXXXXXX
Start with the TPS library traceline, thats where I learned how to make a good traceline. That traceline isn't the best but it will do for now. Some things you'd like to know is that it seraches like from 1 to 100 so there are 100 circles with a fixed radius that seraches units in a line with the direction of the camera from the player's unit. That is the most important thing about that traceline. Then when it finds a target it compares its custom value which is what the creator sets that units height as. Using this he compares it with the function of the angle of tangent with the camera to determine if its within range. if it is its a hit and set the target as that unit.
Basically, its a line which seraches for dots. In an rts stand point, its easier to make a game with dots instead of rag dolls. The rts system places models for these dots which is what you see. But looking inside the game itself, they are all basically flats dots on a flat 2d plane with a radius.
If you still need help we can talk on skype/vent just pm me
Would you care to explain how this idea differs from my traceline? Also once my standard traceline detects a target you can simunlate randomess of the projectile with separate triggers. Also most of what you said is generally incoherent. He would have no idea how to build a traceline from what you said, because even I don't know what you said (except that last paragraph that describes how to make a simple traceline which is an exact replica of mine).
You can make the radius of seach circle along the traceline larger as the distance along the traceline increases with the formula r = X/N * f(z) where f(z) is a function of z. This would counter the perspective problem of a narrowing traceline over distance.
Listen, just look at my traceline, ultimately every non-physics based traceline has to do EXACTLY what I did. There are no shortcuts, all of these calculations must be performed at one time or another no matter what algebraic traceline you decide to make.
If you have any questions about specific parts of the traceline just tell me. Also any modern computer can handle this trigger being executed 16 times per second (16xN checks per seconds). My task manger in Windows doesn't even show a noticeable increase in CPU usage when 12 of these tracelines are running at the same time.
EDIT:
Also if you were really afraid of CPU issues, you could remove all events from the trigger and set the trigger as initially off. Then when an event occurs like a Mouse Click for an attacking you could setup the following:
Run Trigger "Traceline" ignoring conditions and WAIT until it finishes. Then continue as normal since your TraceUnit has been found.
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
Unitfound - why not just use if closest unit in region =/ no unit instead create a variable just for this. save space
This should all be 1 trigger, it seems you divided this into 2 seperate triggers.
Its also not only about CPU issues, its about if this is every possible once you had a ton other things into the map. If you have a looping trigger where you dont' actually need one its just inefficent triggering 101. Also having it possible to run it online with 14+ players. That is the perfect traceline. If your using this loop solely just for single player use then whatever.
There is also a 'second' way of making a traceline. It uses the angle of the targets angle of the player to determine if they are within range. Basically get the angle of every unit from the unit to the player's unit and from the player's yaw compare that and see if it matches. Its much much much less cpu heavy and doesn't require all this search radius stuff. Just a little nipit :).
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
@EdwardSolomon: Go
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
------------------------------------------------------------------------------------------------------------------------------------
1) The Event doesn't have to be periodic. The event can be whatever you want it to be, since it doesn't effect the mechanics of the traceline. In my maps I need to constantly know if there is a unit in his line of fire, even if he isn't shooting (for AI purposes). So in my case (and perhaps many other cases) the periodic execution is needed.
You are right about z and wrong about c. Z is a useless variable since is equals the Picked Integer. I can replace every instance of z with the function Picked Integer. However using z makes it more humanly understandable and easier to read. Also, if you're concerned about efficient triggering 101, it would more useful to establish z = Picked Integer and use z from there on end, then to keep using Picked Integer since the bit-length of the the letter z is smaller than the bit-length of Picked Integer.
You are wrong about the variable c. C records the number of failed attempts and is used OUTSIDE the integer loop at the end. I cannot refer to Picked Integer as a function where Picked Integer is not defined.
What are you even talking about with the UG variable? If there was 100 units in front of you UG is not going to detect all 100 units at the same time, just the small amount of units that are currently within the small circle with a radius of X/N units. So if there's a 100 units in front of you and your traceline is 50 units long and you perform 50 checks, the cardinality of UG will only average 2 units per check.
I think you need to read through my whole trigger. It appears that you are fundamentally confused. Also why don't you actually help the OP and give him a step-by-step guide on how to do it.
Also since I'm such an idiot according to you, why don't you rewrite my trigger for me as well and prove I'm an idiot.
Also recall that he is asking for help. First he needs to understand a traceline conceptually and create a traceline that matches the concept perfectly. He can then makes changes after he understands his traceline function to make it more efficient for a computer to read (what computers find easier to read may be more confusing to a human).
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
@EdwardSolomon: Go
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
----
1) The Event doesn't have to be periodic. The event can be whatever you want it to be, since it doesn't effect the mechanics of the traceline. In my maps I need to constantly know if there is a unit in his line of fire, even if he isn't shooting (for AI purposes). So in my case (and perhaps many other cases, the periodic execution is needed).
You are right about z and wrong about c. Z is a useless variable since is equals the Picked Integer. I can replace every instance of z with the function Picked Integer. However using z makes it more humanly understandable and easier to read. Also, if you're concerned about efficient triggering 101, it would more useful to establish z = Picked Integer and use z from there on end, then to keep using Picked Integer since the bit-length of the the letter z is smaller than the bit-length of Picked Integer.
You are wrong about the variable c. C records the number of failed attempts and is used OUTSIDE the integer loop at the end. I cannot refer to Picked Integer is a function where Picked Integer is not defined.
What are you even talking about with the UG variable? If there was 100 units in front of you UG is not going to detect all 100 units at the same time, just the small amount of units that are currently within the small circle with a radius of X/N units. So if there's a 100 units in front of you and your traceline is 50 units long and you perform 50 checks, the cardinality of UG will only average 2 units per check.
I think you need to read through my whole trigger. It appears that you are fundamentally confused. Also why don't you actually help the OP and give him a step-bystep guide on how to do it.
Also since I'm such an idiot according to you, why don't you rewrite my trigger for me as well and prove I'm an idiot.
Quote from AtikLYar:
Okay, so I am trying to create Starcraft: Ghost.
I currently have a movement system I very much like. But, the problem is it came with a traceline system I could not get to work no matter how many maps I tried it in or what units I was using.
I then looked up another traceline tutorial that used a custom script filled with syntax errors.
I looked up some youtube videos that said you can just oder your unit to start attacking in the direction they are facing, but I can't figure out how.
All I am asking for is a step by step guide on how to make my unit launch an attack in the direction I am looking. And yes, I have spent multiple hours looking for one and couldn't find one.
It is of my opinion that Gamfvr has no intention of meeting the requests of the OP (you). The OP is looking for a step-by-step guide on how to create a traceline. Gamfvr nevers offers such a guide and only hints at how to create certain apsects through abstract methods.
It is of my opinion that the OP does not understand the very basics of a traceline and thus is NOT looking for an abstract alternative to a conventional traceline. The OP is simply looking for a simple traceline function and wants to know how it works.
I have provided him with such a function and explained it very thoroughly and I am open to more questions if needed. Every time Gamfvr comments on my Traceline he discredits it and confuses the OP (meanwhile the traceline works perfectly so i don't know why he is doing this). I can only conclude that Gamfvr is either Trolling or actually lacks the knowledge to answer the OP's question. In either case his replies should be ignored thus far.
And accusing me of calling you an idiot since I was just simply stating that your traceline doesn't fit the 'simple' aspect that the OP needs. This doesn't have to turn into an argument. A 'simple' traceline would be that TPS traceline library. Which what I recommended him to start with. That is the down right basic traceline possible and for him to make his own traceline out of your image is very unlikely when he doesn't even understand the library sample. I only hinted on certain aspects because its just food for thought. I won't right out a complex guide unless he really really wants to make it. You don't have to go down low and call me a troll or lack of knowledge when we are just discussing. This isn't middle school. We are just discussing calm down. I am neither of those just watch my vids on StrikeCraft, I worked with tracelines for 6+ months, even created a traceline for grenades which can bounce off walls and replicate what you would see in a real fps. I am not a noob at this stuff.
You never stated anywhere that you were going to use these variables for other instances in your system. Reason why I thought the periodic event is useless. Remember the topic is about just applying a hit on a target with a traceline not about other things running in the background that you might have unless you state otherwise. Since the OP wanted just a 'simple' traceline it would be better to just have 1 trigger. This goes back to the Z and C variables where if I didn't know you'd use these variables for other triggers I would deem them useless in my point of view as I have no use of these variables anyway in my system because I do not need to use C for my hit/miss system.
As for the OP, I've already explained the basics of the traceline. You do not need to right a guide for him if its just a simple number he didn't change which is most likely what has happened here. If all he really did was use the TPS library and didn't change anything in the triggers. Then he didn't add a custom value for the units on the map. So that is why possiblity he can't hit any targets because there is no height to them.
Camera Yaw will give you the correct direction to fire in. You can make a 2-d traceline (IE no way to detect if you flying units or anything) very easy by just creating an ability with a projectile and ordering a cast in that direction.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
Camera Yaw will give you the correct direction to fire in. You can make a 2-d traceline (IE no way to detect if you flying units or anything) very easy by just creating an ability with a projectile and ordering a cast in that direction.
It won't it will just go over a terrian unless u place valiators to be the same cliff level and it will destory itself. Its basically placing a persistent behavior on a unit that searches the area for any targets. You launch the missile with the ability or my ordering the target to use the ability at a point. Then the behavior will do its job. Only problem is it won't target flying units, only ground units and its not as dynamic as a real traceline. This is all done in the data editor. It won't do any 3d collosion just 2d collosion. Kinda like what you see in battlefield:egypt. You won't be able to shoot at units on a cliff unless your on the same cliff level.
Above points are correct. The ability will skip over cliffs as if they are not there unless you stick a terrain height validator in there. But that's not a big deal, shouldn't take more than a few clicks. Again, as stated above, it's 2-d only, so you cannot detect a headshot or if you shot too low or anything.
Anyways, I would highly recommend this tutorial. Kueken did a fantastic job with it, and I use it frequently if I need a reference to build any complex missiles with no target. Make an ability like one of those, and then when the player clicks (or hits the fire button, whatever...) do something like this:
Good luck, and as always, feel totally free to send me a PM if you have any questions. I'm starting school again, so I won't be online 24/7. But you should get an answer within 24 hours.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
Okay, so I am trying to create Starcraft: Ghost.
I currently have a movement system I very much like. But, the problem is it came with a traceline system I could not get to work no matter how many maps I tried it in or what units I was using.
I then looked up another traceline tutorial that used a custom script filled with syntax errors.
I looked up some youtube videos that said you can just oder your unit to start attacking in the direction they are facing, but I can't figure out how.
All I am asking for is a step by step guide on how to make my unit launch an attack in the direction I am looking. And yes, I have spent multiple hours looking for one and couldn't find one.
@AtikLYar
I'll give you the general guideline of how to make a 3D traceline. I made a 12-player 3D Traceline function about a year ago with very simple commands (a single trigger that calculated 12 different tracelines per game loop). I'll explain each section BELOW the trigger. It is expected that you have a good conceptual understanding of trigonometry.
Event: Every 0.0625 seconds of game time.
Conditions: None
Global Variables: TraceUnit (unit) = No Unit.
Local Variables:
Theta (real) = current camera Yaw of player
Phi (real) = -1 * Current camera Pitch of Player
X (real) = [Maximum range of gun]
u (real) = X * Cosine(Phi)
v (real) = X * Sin (Phi)
N (integer) = Number of Checks per loop
p (point) = position of player's unit
r (real) = Radius of Check Circle
temp reg (region) = No region
z (integer) = 0
UG (unit group) = [empty unit group]
h (real) = 0
c (integer) = 0
UnitFound (boolean) = false
Actions:
----------Pick Each Integer from 1 to N and do the following:
If UnitFound = false
then do the following chain of actions:
Set z = picked integer
Set temp reg = Circular Region with radius r at Point P with polar offset z * (u / N) at angle THETA.
Set UG = All units in Temp Reg.
Set h = z * (v / N)
-----------------Pick Each Unit in UG and do the following (this is within the integer loop itself)
---If/Then/Else (within the UG loop that is still within the integer loop).
If Height of the Picked Unit > h - r
If Height of the Picked Unit < h + r
Then set TraceUnit = Picked Unit.
Then set UnitFound=True
Break Loop Unit Group Loop.
Else - Do nothing
If Unit Found = false
Then set c = z
else do nothing
------------
Else
Break Integer Loop:
If c < N
then Do nothing
else Set Traceunit = No Unit.
This post will explain the individual use of each variable and the concept of the traceline. This post also explains the basic mathematical operations and usages of sine and cosine. The post after this one contains detailed guide on how to put them all together.
The Traceunit variable is [unit] type variable. It is the global variable that the traceline itself is meant to evaluate. The reason we make it a global variable is so we can communicate the detected Traceline target to other in-game triggers.
Theta is a [real] variable. Theta tells us the direction (like north, south, east or west) that the camera for our player is facing. We get this value by setting it equal to the current camera Yaw of our Player.
Phi is a [real] variable. Phi tells us the inclination of the players camera. For instance is he looking 45 degrees above the horizon his pitch would be NEGATIVE 45. In Starcraft 2 and most computer applications POSITIVE PITCH is below the horizon and NEGATIVE PITCH is above the horizon. In more advanced calculations involving quaternions this system is preferable. However for something simple like a traceline this really f***s with the mind, so we'll set Phi equal to -1 x Current Camera Pitch of Player.
X is a [real] variable. It is simply the range of the weapon, or more technically the length of the traceline.
u is a [real] variable. This variable is the Horizontal range of your weapon. If your camera inclination equals zero (looking at the horizon), then u is equal to X. However, suppose your were looking straight up at the sky. Your weapon is going to shoot targets on the horizon if you are looking at the top of the sky! In fact the when you're looking straight up, the horizontal range of your weapon is ZERO. So how do we calculate the horizontal range of your weapon at any camera inclination (other than 0 degrees and 90 degrees). Well those good old days of Junior High School Trig should show us the way!
The range of your weapon is in fact always the same (X) as you increase your camera inclination. The trajectory of your weapon forms a RIGHT TRIANGLE with the ground. The angle between the adjacent leg (ground/horizontal leg) and the hypotenuse is equal to the inclination of the Player Camera, in other words Phi. So in order to calculate the length of the horizontal leg we multiply X by Cosine(Phi). Remember adjacent/hypotenuse = cosine(PHI), so we can cross multiply to get X * (cosine Phi) = u. Thus u = x * (cosine Phi).
v is a [real] variable. This variable complements u. It calculates the maximum height that your weapon will shoot at. If your pointing at the horizon, your weapon won't shoot very high, but if you're looking straight up, your weapon will shoot very high into the air! In this case we are trying to calculate the opposite leg of the right triangle. Opposite/Hypotenuse = sin(Phi) such that v = X * sin(Phi).
N is an [integer] variable. This is an interesting number that controls the accuracy of the traceline. This will control how often we check for the presence of a unit in your line of fire, starting from the position of the player and ending at end of the trajectory of your gun. Basically it takes the length of the trajectory and cuts it into N equal pieces.
Imagine that we put a tick mark (like on a ruler) at each of these points that we "cut" the trajectory line. We are going to create a circular region at each of these points and check to see if there's a unit inside of them. We will start at the first tick mark located next to the player's controlled unit. If we don't find a unit in this circle we move on to the next tick mark and see if there's a unit located in that region. If not, we move on again until we find a unit within a circle around one of the tick marks. If we never find a unit at the end of the trajectory (the circle around the last tick mark) it means that their is no unit in the line of fire.
Ok so how do we do this? Read on!
temp region is a [region] variable. This variable will be used as the circular region that we are temporarily checking for units around a specific tick mark.
r is a [real] variable. This determines the radius of the circle Temp region. We want the circles from one tick mark to the next to overlap for accuracy. So if X is divided into N segments, by setting the radius of each circle to X/N we ensure the the edge of each circle makes contact with the center of the previous circle.
z is an [integer] variable. z will be used to keep track of which Tick Mark we are at.
UG is a [unit group] variable. This variable will be set to the collection of units inside our temp region while checking a specific tick mark.
h is a [real] variable. h determines the height of a tick mark along the trajectory (relative to the ground). If we're shooting at a target in the air, we need to make sure that when we detect a unit in the circular region, that the unit isn't too high or too far below the trajectory line in 3D space. In actuality, when we create circular regions on the ground, we are actually creating 3D cylinders with an infinite height. Thus we need to ignore units that are above or below the trajectory height at the specific Tick Mark we are checking.
To do this we need to calculate the height of the tick mark itself. Thankfully we can use the fact that similar triangles are proportional to each other. We know that X has been cut into N parts, so the height difference between each tick mark is v/N. Thus the height at any particular tick mark (z) is equal to z * (v/N). So h = z * (v/N).
UnitFound is a [boolean] variable. Boolean variables are either True or False. If a unit is found in any of the Checks, we want to set this variable equal to True. This will allow us to STOP the trigger so that it doesn't continue. Once a unit is found, we don't want it to find more units!
c is an [integer] variable. This variable is used if NO UNITS ARE FOUND at the END of the trigger. Basically if c = N at the end of the trigger, then no units were found. In that case we set TraceUnit = No Unit (default. value). Another way of looking at it c is that it records how many failed attempts occurred. After N failed attempts we know there is no unit in the traceline.
Now let's actually make the trigger. So we're going to start with an integer loop. This will be from 1 to N. This is because we are cutting X into N parts and we need to check at each of the N tick marks.
Once the Integer loop is setup, selection the action "If Then Else." Put the following condition in the IF statement "If UnitFound = false." We do this to make sure that we haven't found a unit at any of the previous tick marks.
Now we're going to put an action in the ELSE (not the THEN) part. Put the action "Break." We do this to make sure that if a unit is found at a previous tick mark, that the trigger itself stops searching for more units.
Now go back to the THEN. Everything that we are going to do from here is contained with this THEN. Set z to the picked integer. This keeps track of which tick mark we are checking for units.
Now we need to create a circular region at our tick mark. To do that we need the horizontal distance of our tick mark from the position of the player's camera. So Knowing that we cut X into N parts, then we also cut "u" into N parts (u is the length of the horizontal leg of the triangle). That means each tick mark is a distance of u/N apart, such that the total distance of a specific tick mark from the player's camera is given by z * (u/N).
Now set the region variable "temp reg" equal to Circle with radius "r" at point "p" with polar offset by (z *(u/N)) at angle THETA (facing of the player's camera).
Now set UG equal to all units inside of temp reg. This gives us a collection of units in the region.
Now we're going to check the heights of each unit in this region to ensure they aren't too far above or below our trajectory line. So set h equal to the height of the tick mark from the ground. This is given by z * (v/N). So h = z*(v/N).
Select the "Pick every unit in unit group" action and select UG as the unit group.
Now under that Pick Every Unit action put an "If then Else" and put the two conditions:
If height of Picked Unit is less than h + r
If height of Picked Unit is greater than h - r
We use +/- r in this conditions in order to give us some "breathing room" because the chances of a unit being having the EXACT height of h are practically zero (a unit with height 13.98 wouldn't' be detected if h was 14, so we need the +/- r to give us a more realistic effect).
In the Then command put
Set TraceUnit = Picked Unit
Set UnitFound = True
Break (this stops the traceline from trying to find more units after it found a unit).
In the else command put NOTHING (leave it blank).
Now create a new action outside the Pick Every Unit action (but still within the integer loop) and select IF THEN ELSE and make the condition If UnitFound= false, then set c = z and leave the ELSE command blank again.
Now finally create a new action OUTSIDE the integer loop and add the following IF THEN ELSE
If c < n
Then (leave blank)
Else Set TraceUnit = No unit.
This last part ensures that if no unit is found along the trajectory that our gun doesn't shoot at a random unit. For instance say you were shooting a unit, but turned your camera 90 degrees to the right and started to shoot at nothing, since no new unit was found in the traceline, your gun would accidentally continue shooting at the target 90 degrees to your left since the TraceUnit target wasn't reset to No Unit!
Also, you may notice there are two breaks in this trigger that activate when a unit is found. The first break is in the Pick Every Unit series of actions. This fires to stop the game from checking other units in the unit group. The game then goes back to the top of the trigger and starts at the next value of z in the integer loop. However the condition UnitFound is now equal to true, so it skips to the ELSE part that says "Break." This second Break stops the integer loop, which in turn prevents it from returning to the Pick Every Unit loop.
If a unit is found before the final integer loop completes, then c will always be less than N and therefore the set TraceUNit = no Unit has no way of ever being fired by accident if a unit is found.
@EdwardSolomon: Go
to be honest ur traceline is very cp heavy due to it being a looping trigger with a bunch of calculations. You should instead be using for every mouse clicked event to start it off. No reason to have a looping traaceline. It has too many vaariables and theirs a much simpler triggering format to get the same and even better effect.
@AtikLYar: Go
I would start off by looking at the TPS engine in the trigger library. That is where I started my traceline. Try to understand that first before you go make your very own traceline. My current traceline from StrikeCraft currently includes many variables. Detects any ground height, detects if theres a ground height in front of you so you can't shoot across it, 3d projectile collosion in space, accuarcy which gives some randomness, recoil, range. Then on top of that creating a system for the weapons themselves such as zoom amount, bullets per shot, attack speed, max spread on crosshairs, aim amount, ammo, max spread while hip firing, ammo tracking for items dropped, auto pick up system. I had to figure an effective and easy way to create a cover system that didn't require too many variables and messy if then statements. Inorder to that point I had to go thur tons of traceline experiments and tons of reorganizing and trashing of older systems. This is complex stuff. If you want to go the full 9 yards your also gunna have to worry about making a traceline for grenades with the bounce effect.
Now dont' be scared.
There are couple shortcuts/complex ways of making a traceline. If you don't want a complex traceline that doesn't include the accuarcy x and y with the dynamic moving crosshairs. I'd recommend do this with trigger and data based. For example, order the unit to attack the unit when the traceline finds a unit. Then the data has validators which stop the unit from attacking so you only attack him once. This is a more easier approach where you can just change a few numbers in the data and ur good to go. Have the weapons as items but have them equip the weapon if they carry them so their weapon changes with it therefore the effect of the attack aswell. But the problem here is that its messy when it comes to 3d projectile and having effects and explosives to hit the ground if you miss due to the fact that you have to create another system that focuses on that.
If you want a complex traceline like mine. I use effects at point and unit to create those explosions at the ground and air. Your going to need algorthirms. I use the data only for making effects, actors and items. But again its pretty tough to make a true replica fps system from an rts system. I too am still working out the kinks but its pretty dam close atm. I do accuarcy a bit differently then the post above. I try to replicate a real life traceline so there would be an X accuarcy in degrees which will force the traceline in a random degree starting direction. Then I have a random real which adds to my comparing condition. The Y is related to the crosshair and so is the X, so all I need to change is the crosshair and it also changes the X and Y. So less mess and work.
Overall, if you want to make a traceline try to make it with the minimal amount of variables needed and try not to make it too complex then it needs to be. Reason why I tend to build the system really messy and over time I trim the fat off it and get it really clean. unless you plan to make this single player but in my case I plan to have this traceline run for 14 players so I can't have that amount of freedom.
Start with the TPS library traceline, thats where I learned how to make a good traceline. That traceline isn't the best but it will do for now. Some things you'd like to know is that it seraches like from 1 to 100 so there are 100 circles with a fixed radius that seraches units in a line with the direction of the camera from the player's unit. That is the most important thing about that traceline. Then when it finds a target it compares its custom value which is what the creator sets that units height as. Using this he compares it with the function of the angle of tangent with the camera to determine if its within range. if it is its a hit and set the target as that unit.
Basically, its a line which seraches for dots. In an rts stand point, its easier to make a game with dots instead of rag dolls. The rts system places models for these dots which is what you see. But looking inside the game itself, they are all basically flats dots on a flat 2d plane with a radius.
If you still need help we can talk on skype/vent just pm me
@gamfvr: Go
nice "Thanks" for his effort.
@gamfvr:
That is actually the first one I was talking about. Even after extended discussion with the creator, no map I tried that traceline in would work no matter what combination of units I attempted. I even uninstalled and reinstalled my entire editor in the possibility it might be a glitched editor and still could not get the traceline to work at all.
Thank you for the help everyone.
Would you care to explain how this idea differs from my traceline? Also once my standard traceline detects a target you can simunlate randomess of the projectile with separate triggers. Also most of what you said is generally incoherent. He would have no idea how to build a traceline from what you said, because even I don't know what you said (except that last paragraph that describes how to make a simple traceline which is an exact replica of mine).
You can make the radius of seach circle along the traceline larger as the distance along the traceline increases with the formula r = X/N * f(z) where f(z) is a function of z. This would counter the perspective problem of a narrowing traceline over distance.
Listen, just look at my traceline, ultimately every non-physics based traceline has to do EXACTLY what I did. There are no shortcuts, all of these calculations must be performed at one time or another no matter what algebraic traceline you decide to make.
If you have any questions about specific parts of the traceline just tell me. Also any modern computer can handle this trigger being executed 16 times per second (16xN checks per seconds). My task manger in Windows doesn't even show a noticeable increase in CPU usage when 12 of these tracelines are running at the same time.
EDIT: Also if you were really afraid of CPU issues, you could remove all events from the trigger and set the trigger as initially off. Then when an event occurs like a Mouse Click for an attacking you could setup the following: Run Trigger "Traceline" ignoring conditions and WAIT until it finishes. Then continue as normal since your TraceUnit has been found.
@AtikLYar: Go
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
@EdwardSolomon: Go
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
Unitfound - why not just use if closest unit in region =/ no unit instead create a variable just for this. save space
This should all be 1 trigger, it seems you divided this into 2 seperate triggers.
Its also not only about CPU issues, its about if this is every possible once you had a ton other things into the map. If you have a looping trigger where you dont' actually need one its just inefficent triggering 101. Also having it possible to run it online with 14+ players. That is the perfect traceline. If your using this loop solely just for single player use then whatever.
There is also a 'second' way of making a traceline. It uses the angle of the targets angle of the player to determine if they are within range. Basically get the angle of every unit from the unit to the player's unit and from the player's yaw compare that and see if it matches. Its much much much less cpu heavy and doesn't require all this search radius stuff. Just a little nipit :).
Quote from gamfvr:
@AtikLYar: Go
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
@EdwardSolomon: Go
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
------------------------------------------------------------------------------------------------------------------------------------
1) The Event doesn't have to be periodic. The event can be whatever you want it to be, since it doesn't effect the mechanics of the traceline. In my maps I need to constantly know if there is a unit in his line of fire, even if he isn't shooting (for AI purposes). So in my case (and perhaps many other cases) the periodic execution is needed.
You are right about z and wrong about c. Z is a useless variable since is equals the Picked Integer. I can replace every instance of z with the function Picked Integer. However using z makes it more humanly understandable and easier to read. Also, if you're concerned about efficient triggering 101, it would more useful to establish z = Picked Integer and use z from there on end, then to keep using Picked Integer since the bit-length of the the letter z is smaller than the bit-length of Picked Integer.
You are wrong about the variable c. C records the number of failed attempts and is used OUTSIDE the integer loop at the end. I cannot refer to Picked Integer as a function where Picked Integer is not defined.
What are you even talking about with the UG variable? If there was 100 units in front of you UG is not going to detect all 100 units at the same time, just the small amount of units that are currently within the small circle with a radius of X/N units. So if there's a 100 units in front of you and your traceline is 50 units long and you perform 50 checks, the cardinality of UG will only average 2 units per check.
I think you need to read through my whole trigger. It appears that you are fundamentally confused. Also why don't you actually help the OP and give him a step-by-step guide on how to do it.
Also since I'm such an idiot according to you, why don't you rewrite my trigger for me as well and prove I'm an idiot.
Also recall that he is asking for help. First he needs to understand a traceline conceptually and create a traceline that matches the concept perfectly. He can then makes changes after he understands his traceline function to make it more efficient for a computer to read (what computers find easier to read may be more confusing to a human).
Quote from gamfvr:
@AtikLYar: Go
Then its not about the traceline its more about the map and what you did to it. Did you set a custom value to the target you are using for its height? That is prob your main problem. And I don't remember what he uses to filter the search so you might wanta check if your units are within that filter, whether they are allied or not.
@EdwardSolomon: Go
If i understood ur traceline correctly. You could first have the event as a mouse click event instead of looping. Why are you looping for no reason when he isn't shooting.
C and Z are useless variables. You could have instead used one integer and use the function for each integer and be done with it. Without doing all this if c =z or if c < N. Once the integer reaches the end you can just use if target = no unit. And if target = any unit then stop the function and create the effect on the target. Makes all those calculations useless. You have somewhat similar but you have extra if thens for the C and Z. You could just compare it with the int that u used for the for each integer.
UG - Unless you are making a spell that does the effect in a line, it would only be useful for having this but again it would create tons of lag if you have 100 units in front of you and more better if just use the data editor for this search. Should just use closest unit in region. Will still do the same job for ur tick mark system.
----
1) The Event doesn't have to be periodic. The event can be whatever you want it to be, since it doesn't effect the mechanics of the traceline. In my maps I need to constantly know if there is a unit in his line of fire, even if he isn't shooting (for AI purposes). So in my case (and perhaps many other cases, the periodic execution is needed).
You are right about z and wrong about c. Z is a useless variable since is equals the Picked Integer. I can replace every instance of z with the function Picked Integer. However using z makes it more humanly understandable and easier to read. Also, if you're concerned about efficient triggering 101, it would more useful to establish z = Picked Integer and use z from there on end, then to keep using Picked Integer since the bit-length of the the letter z is smaller than the bit-length of Picked Integer.
You are wrong about the variable c. C records the number of failed attempts and is used OUTSIDE the integer loop at the end. I cannot refer to Picked Integer is a function where Picked Integer is not defined.
What are you even talking about with the UG variable? If there was 100 units in front of you UG is not going to detect all 100 units at the same time, just the small amount of units that are currently within the small circle with a radius of X/N units. So if there's a 100 units in front of you and your traceline is 50 units long and you perform 50 checks, the cardinality of UG will only average 2 units per check.
I think you need to read through my whole trigger. It appears that you are fundamentally confused. Also why don't you actually help the OP and give him a step-bystep guide on how to do it.
Also since I'm such an idiot according to you, why don't you rewrite my trigger for me as well and prove I'm an idiot.
Quote from AtikLYar: Okay, so I am trying to create Starcraft: Ghost.
I currently have a movement system I very much like. But, the problem is it came with a traceline system I could not get to work no matter how many maps I tried it in or what units I was using.
I then looked up another traceline tutorial that used a custom script filled with syntax errors.
I looked up some youtube videos that said you can just oder your unit to start attacking in the direction they are facing, but I can't figure out how.
All I am asking for is a step by step guide on how to make my unit launch an attack in the direction I am looking. And yes, I have spent multiple hours looking for one and couldn't find one.
It is of my opinion that Gamfvr has no intention of meeting the requests of the OP (you). The OP is looking for a step-by-step guide on how to create a traceline. Gamfvr nevers offers such a guide and only hints at how to create certain apsects through abstract methods.
It is of my opinion that the OP does not understand the very basics of a traceline and thus is NOT looking for an abstract alternative to a conventional traceline. The OP is simply looking for a simple traceline function and wants to know how it works.
I have provided him with such a function and explained it very thoroughly and I am open to more questions if needed. Every time Gamfvr comments on my Traceline he discredits it and confuses the OP (meanwhile the traceline works perfectly so i don't know why he is doing this). I can only conclude that Gamfvr is either Trolling or actually lacks the knowledge to answer the OP's question. In either case his replies should be ignored thus far.
@EdwardSolomon: Go
And accusing me of calling you an idiot since I was just simply stating that your traceline doesn't fit the 'simple' aspect that the OP needs. This doesn't have to turn into an argument. A 'simple' traceline would be that TPS traceline library. Which what I recommended him to start with. That is the down right basic traceline possible and for him to make his own traceline out of your image is very unlikely when he doesn't even understand the library sample. I only hinted on certain aspects because its just food for thought. I won't right out a complex guide unless he really really wants to make it. You don't have to go down low and call me a troll or lack of knowledge when we are just discussing. This isn't middle school. We are just discussing calm down. I am neither of those just watch my vids on StrikeCraft, I worked with tracelines for 6+ months, even created a traceline for grenades which can bounce off walls and replicate what you would see in a real fps. I am not a noob at this stuff.
You never stated anywhere that you were going to use these variables for other instances in your system. Reason why I thought the periodic event is useless. Remember the topic is about just applying a hit on a target with a traceline not about other things running in the background that you might have unless you state otherwise. Since the OP wanted just a 'simple' traceline it would be better to just have 1 trigger. This goes back to the Z and C variables where if I didn't know you'd use these variables for other triggers I would deem them useless in my point of view as I have no use of these variables anyway in my system because I do not need to use C for my hit/miss system.
As for the OP, I've already explained the basics of the traceline. You do not need to right a guide for him if its just a simple number he didn't change which is most likely what has happened here. If all he really did was use the TPS library and didn't change anything in the triggers. Then he didn't add a custom value for the units on the map. So that is why possiblity he can't hit any targets because there is no height to them.
Haven't read these posts, but...
Camera Yaw will give you the correct direction to fire in. You can make a 2-d traceline (IE no way to detect if you flying units or anything) very easy by just creating an ability with a projectile and ordering a cast in that direction.
How would this work with ramps and varied terran?
Because this is EXACTLY what I was asking for.
@AtikLYar: Go
It won't it will just go over a terrian unless u place valiators to be the same cliff level and it will destory itself. Its basically placing a persistent behavior on a unit that searches the area for any targets. You launch the missile with the ability or my ordering the target to use the ability at a point. Then the behavior will do its job. Only problem is it won't target flying units, only ground units and its not as dynamic as a real traceline. This is all done in the data editor. It won't do any 3d collosion just 2d collosion. Kinda like what you see in battlefield:egypt. You won't be able to shoot at units on a cliff unless your on the same cliff level.
@gamfvr: Go
Above points are correct. The ability will skip over cliffs as if they are not there unless you stick a terrain height validator in there. But that's not a big deal, shouldn't take more than a few clicks. Again, as stated above, it's 2-d only, so you cannot detect a headshot or if you shot too low or anything.
Anyways, I would highly recommend this tutorial. Kueken did a fantastic job with it, and I use it frequently if I need a reference to build any complex missiles with no target. Make an ability like one of those, and then when the player clicks (or hits the fire button, whatever...) do something like this:
Good luck, and as always, feel totally free to send me a PM if you have any questions. I'm starting school again, so I won't be online 24/7. But you should get an answer within 24 hours.
That is exactly what I am looking for, is what I saw in battlefield.
If I had the flying unit right against the ground and turned on ground collision could I shoot it?
@AtikLYar: Go
Yes you can you can also make the behavior search for flying units or change the flying unit pathing plane to ground. either way works
this means u can have the fly unit's height like 13 but still hit it even tho the projectile doesn't seem to hit it.
In that event, thank you.
The fact that I can now have arial battles with no player interferance is a bonus even.
Now I can finally get workig, as long as I keep that in mind for level design.
I'm assuming setting a normal range for the ability will set the range of the 'traceline'?