Good day.
I'm stuck with math here, I'll need help.
There are situations in my project where an actor needs to face the player. (Just by the angle, not the pitch).
I haven't been able to figure out the math. Just setting the angle of the actor to the "inverted" angle of the player (by multiplying it with -1) doesn't produce the right result.
I'm aware of SetActorAngle but I'm unable to figure out how to properly calclate the angle necessary.
Does somebody have an idea how to solve this? Help would be greatly appreciated.
[ACS] - Making an actor face the player
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 392
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ACS] - Making an actor face the player
quickest way to "invert" an angle is to add (or subtract) 180
-
- Posts: 277
- Joined: Fri Feb 21, 2014 5:04 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Montana, USA
Re: [ACS] - Making an actor face the player
Have you tried A_Face with the max_pitch property set to 270?
-
- Posts: 392
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ACS] - Making an actor face the player
Yeah I was going to suggest A_Face also but I looked at the wiki and it says Zscript only
-
-
- Posts: 590
- Joined: Thu Jul 05, 2007 6:13 pm
Re: [ACS] - Making an actor face the player
If you need something that works for any actor given a tid, you can do this:
ang now has the property that SetActorAngle(thing_tid, ang) will make the thing face the activator. For reference, you can do pitch similarly:
Code: Select all
// assume that the player is the activator.
int diff_x = GetActorX(0) - GetActorX(thing_tid);
int diff_y = GetActorY(0) - GetActorY(thing_tid);
int ang = VectorAngle(diff_x, diff_y);
Code: Select all
int diff_z = GetActorZ(0) - GetActorZ(thing_tid);
int vang = VectorAngle(VectorLength(diff_x, diff_y), diff_z);
-
- Posts: 8
- Joined: Tue Jun 28, 2022 1:07 pm
Re: [ACS] - Making an actor face the player
@KeksDose
That works. Thank you for your help!
That works. Thank you for your help!
That's true. Though I tried it and inverting doesn't do the right thing in this situation.Sir Robin wrote:quickest way to "invert" an angle is to add (or subtract) 180
-
-
- Posts: 590
- Joined: Thu Jul 05, 2007 6:13 pm
Re: [ACS] - Making an actor face the player
oh yea I forgot to mention! in acs, actor angles are fixed point range, which is 0 to 1.0 with the .0 (1 and 1.0 are not the same here is what I'm saying), so you can reverse angles by adding 0.5.