GetLineAngle?
Moderator: GZDoom Developers
GetLineAngle?
an ACS Function to return the angle of a linedef would be nice, It'd be useful to change an actor's angle based on the value returned from a linedef angle, a tag of 0 would return the angle of the linedef the script was activated from, in a similar fashion to LineSide.
Re: GetLineAngle?
This is better suited for, and also already do-able through ZScript, I think.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: GetLineAngle?
Agreed. I will no longer consider features for ACS that go beyond simple map action scripting. Use ZScript for such tasks.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: GetLineAngle?
How do you do this in ZScript though? Is there a special pre-calculated thing we can use, or just atan2 and the vertex positions?
(also how do you tell if an angle is 170 degrees or -10 (or 350 or -190)?)
(also how do you tell if an angle is 170 degrees or -10 (or 350 or -190)?)
Re: GetLineAngle?
Manual calculation for now. GZDoom could use a built-in way to simply get the line angle in degrees.
(I don't badly need it right now and I currently use the atan2 way which is enough for what small use context I have, but anyone else feel free to make a new suggestion)
(I don't badly need it right now and I currently use the atan2 way which is enough for what small use context I have, but anyone else feel free to make a new suggestion)
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: GetLineAngle?
Can you give some example code on how you do it?
-
- Posts: 219
- Joined: Wed Jan 08, 2014 8:40 am
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: GetLineAngle?
Code: Select all
double lineAngle = atan2(line.v1.p.Y - line.v2.p.Y, line.v1.p.X - line.v2.p.X;
Code: Select all
FLineTraceData CheckLines;
LineTrace(angle, distance, pitch, data: CheckLines);
- phantombeta
- Posts: 2084
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: GetLineAngle?
Or you could just use the pre-calculated delta value from the Line struct, which is both a small optimization and something that makes the code way more readable.XxMiltenXx wrote:Code: Select all
double lineAngle = atan2(line.v1.p.Y - line.v2.p.Y, line.v1.p.X - line.v2.p.X;
Code: Select all
double lineAngle = atan2 (l.delta.Y, l.delta.X);
-
- Posts: 219
- Joined: Wed Jan 08, 2014 8:40 am
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: GetLineAngle?
Ah, yes. This certainly makes it better. Thanksphantombeta wrote: Or you could just use the pre-calculated delta value from the Line struct, which is both a small optimization and something that makes the code way more readable.Something like this.Code: Select all
double lineAngle = atan2 (l.delta.Y, l.delta.X);