Smooth monster turning for A_FaceTarget?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
User avatar
Mini--Joe
Posts: 97
Joined: Sun Jul 27, 2014 10:25 am

Smooth monster turning for A_FaceTarget?

Post by Mini--Joe »

What I want to do is find the direction a monster has to turn in order to face its target, then play one of two animations to make it look nice.
It is fine for sprites to snap-turn to face the target, because sprites are always snapping to other frames, and the visual distance doesn't actually change. But for 3d models, it doesn't look very good.
Is this possible at all?
User avatar
Cherno
Posts: 1337
Joined: Tue Dec 06, 2016 11:25 am

Re: Smooth monster turning for A_FaceTarget?

Post by Cherno »

Yes, it is certainly possible. I have implemented behavior like this in my Voxel Chibi Doom! mod, along with support for A_Chase. It is fairly complex behavior and needs customized actor states as well as ZScript.
User avatar
Mini--Joe
Posts: 97
Joined: Sun Jul 27, 2014 10:25 am

Re: Smooth monster turning for A_FaceTarget?

Post by Mini--Joe »

Cherno wrote:Yes, it is certainly possible. I have implemented behavior like this in my Voxel Chibi Doom! mod, along with support for A_Chase. It is fairly complex behavior and needs customized actor states as well as ZScript.

How did you do it? I assume it has something to do with finding the angle of the player and the calling monster.
User avatar
Cherno
Posts: 1337
Joined: Tue Dec 06, 2016 11:25 am

Re: Smooth monster turning for A_FaceTarget?

Post by Cherno »

No. Basically, when calling any function that results in a change of angle, you store the new angle as a target that should be reached. The actor's angle is then reset to what it was before. Also, the current state is stored. In Tick(), if the stored state is not null, and CurState is equal to the stored state, the actor's angle is increased/decreased a bit towards the target angle.

Download Voxel Chibi Doom! and look at the ActorBase code, it should be in there.
Post Reply

Return to “Scripting”