The question is straight forward enough, how do I go about interacting with the turrets of a unit? Specifically, how do I set their rotation/facing direction through triggers?
Many people, including me (^.^), have tried finding that out and failed miserably.
The only clue I have is that you can probably address the actor turret (turrets have their own actors) through the actor unit via a certain name. I tried giving the turret a certain name or searching for the right name to get the turret, but to no avail.
You're going to kick yourselves when you realise how easily this is done. I'll make a demo later today if I have time, and upload the map soon after. Watch this space!
That only works in some cases. For sieged Siege tanks or for Autoturrets that might work fine, but for unsieged Tanks or hellions it'll simply rotate the entire unit, not only the turret.
What we're searching is a way to rotate ONLY the turret and keep the actual unit facing unchanged.
You're going to kick yourselves when you realise how easily this is done. I'll make a demo later today if I have time, and upload the map soon after. Watch this space!
I have made some progress in my search for a method to rotate turrets (I'm looking at actor messages, specifically AttachSetBearings/AttatchSetRotation) however I still can't get the turret to rotate upon my request. I get the feeling I am on the right track but am using incorrect parameters. I eagerly await your approach.
The easiest way i found is to make a dummy weapon (with turret) that always auto attacks smth - and so it rotates to the "smth". (like a crosshair or whatever)
Sure there might be some other way to do it, but it depends on what you are up to.
From my most recent findings I am certain there is a "proper" way to do this. Using the Siege Tank (Tank Mode) as an example, if you look at the Si Ta Turret actor it has a field called Yaw Query. Looks to me like this is what the turret uses to aquire it's facing direction and, in this case, it is tied to the model attachment point TurretZ (You can find this attachment by looking at the Siege Tank model in the previewer). My current train of thought is that I should be fiddling with this TurretZ attachment's rotation in order to affect the direction the attached turret is facing. Again this goes back to the AttachSetBearings/AttachSetRotation actor messages I am currently looking at. However no matter what set of parameters I pass through this messages I can't seem to get the turret to budge. Still missing something I'm afraid, will keep this post up to date with my results.
Yea, that pretty much were my most recent findings too - with the same result: No matter which parameters I entered it didn't work.
I noticed however that the GUI doesn't accept any rotation value with AttachSetRotation, but even with custom script and inserting it manually it doesn't work.
s3rius, I have discovered that the AttachSetRotation Rotation parameter doesn't take an angle rotation like you might expect. Instead it takes a 3d vector (format: xyz) describing the relative point the actor must face and builds a rotation from that. As an example, try use SetRotation on your base unit with the vector "1,0,0". You should notice it will rotate to face east. Use a vector of "0,1,0" and it will face north, "1,1,0" and it will face North East. Note that using "1,1,0" is the same as using the value "47,47,0" as the projected lines that connect these two points share the same gradient.
Some bad news however, even after getting this AttatchSetRotation to function correctly, it still does not alter the direction of my turret.
Uploaded it and placed a link underneath the video above. If you need any further assistance I'll try and be of help. I will say that my solution is not perfect and I had some other ideas in mind, but this definitely works fine and I'm sure people more talented than me can refine it.
Enjoy!
Ps I know the map has a rather large amount of crude triggers, but this was the first map I ever made and it's purpose was mostly to learn the editor. Please don't pick on it :(
The things you should be interested in are the trigger "Attack Turret" and the data changes I made to the Siege Tank's turret and weapon.
Lol it went through my mind so many times I just idk ha I wanted todo it differently like it felt soo unneeded but you definitely made it work
and other methods rnt working so u win :P
Ah, well then I'm part kicking myself and part disappointed. I figured that there would be a way to actually turn the turret. This seems like a workaround/hack way.
The question is straight forward enough, how do I go about interacting with the turrets of a unit? Specifically, how do I set their rotation/facing direction through triggers?
Many people, including me (^.^), have tried finding that out and failed miserably.
The only clue I have is that you can probably address the actor turret (turrets have their own actors) through the actor unit via a certain name. I tried giving the turret a certain name or searching for the right name to get the turret, but to no avail.
You're going to kick yourselves when you realise how easily this is done. I'll make a demo later today if I have time, and upload the map soon after. Watch this space!
Now I'm interested :)
A turret points in the direction it's "facing." You can use the actions around "Make Unit Face ..." to turn your turret.
That only works in some cases. For sieged Siege tanks or for Autoturrets that might work fine, but for unsieged Tanks or hellions it'll simply rotate the entire unit, not only the turret.
What we're searching is a way to rotate ONLY the turret and keep the actual unit facing unchanged.
I have made some progress in my search for a method to rotate turrets (I'm looking at actor messages, specifically AttachSetBearings/AttatchSetRotation) however I still can't get the turret to rotate upon my request. I get the feeling I am on the right track but am using incorrect parameters. I eagerly await your approach.
@Kalekin: Go
The easiest way i found is to make a dummy weapon (with turret) that always auto attacks smth - and so it rotates to the "smth". (like a crosshair or whatever)
Sure there might be some other way to do it, but it depends on what you are up to.
Also interested in Eiviyn's way
@xhatix: Go
From my most recent findings I am certain there is a "proper" way to do this. Using the Siege Tank (Tank Mode) as an example, if you look at the Si Ta Turret actor it has a field called Yaw Query. Looks to me like this is what the turret uses to aquire it's facing direction and, in this case, it is tied to the model attachment point TurretZ (You can find this attachment by looking at the Siege Tank model in the previewer). My current train of thought is that I should be fiddling with this TurretZ attachment's rotation in order to affect the direction the attached turret is facing. Again this goes back to the AttachSetBearings/AttachSetRotation actor messages I am currently looking at. However no matter what set of parameters I pass through this messages I can't seem to get the turret to budge. Still missing something I'm afraid, will keep this post up to date with my results.
Yea, that pretty much were my most recent findings too - with the same result: No matter which parameters I entered it didn't work.
I noticed however that the GUI doesn't accept any rotation value with AttachSetRotation, but even with custom script and inserting it manually it doesn't work.
@s3rius: Go
s3rius, I have discovered that the AttachSetRotation Rotation parameter doesn't take an angle rotation like you might expect. Instead it takes a 3d vector (format: xyz) describing the relative point the actor must face and builds a rotation from that. As an example, try use SetRotation on your base unit with the vector "1,0,0". You should notice it will rotate to face east. Use a vector of "0,1,0" and it will face north, "1,1,0" and it will face North East. Note that using "1,1,0" is the same as using the value "47,47,0" as the projected lines that connect these two points share the same gradient.
Some bad news however, even after getting this AttatchSetRotation to function correctly, it still does not alter the direction of my turret.
Here is a demo anyway. Is this what you mean by rotating turrets?
Uploaded here:
http://www.sc2mapster.com/maps/catalyst/
Oh my god I need that map. That is what put a halt on my own map-making. Please upload the map.
@Kalekin: Go
That is some nice progress. GJ :)
@Eiviyn: Go
That's pretty much exactly what we are looking for - that tank turning his main weapon.
Would you be so kind to either upload that map or give us the line(s) of code for rotation? (btw, map looks nice).
Uploaded it and placed a link underneath the video above. If you need any further assistance I'll try and be of help. I will say that my solution is not perfect and I had some other ideas in mind, but this definitely works fine and I'm sure people more talented than me can refine it.
Enjoy!
Ps I know the map has a rather large amount of crude triggers, but this was the first map I ever made and it's purpose was mostly to learn the editor. Please don't pick on it :(
The things you should be interested in are the trigger "Attack Turret" and the data changes I made to the Siege Tank's turret and weapon.
So u just make it attack a unit infront of the camera?
Yep. I hope you're not too dissappointed :(
Lol it went through my mind so many times I just idk ha I wanted todo it differently like it felt soo unneeded but you definitely made it work and other methods rnt working so u win :P
Ah, well then I'm part kicking myself and part disappointed. I figured that there would be a way to actually turn the turret. This seems like a workaround/hack way.
@Eiviyn: Go
so it's exactly what i said :x
@Kalekin: Go
have you tried matrices with AttachSetRotation ?
2D-Rotation matrices or even affine ones
as there are different Turret points ( TurretY, TurretZ )
Just tested by myself
They are matrices or 2 vectors generating a angle
ie (1,0,0) (0,1,0) = angle((1,0,0),(0,1,0)) = 90°
resulting in this: