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?
Smooth monster turning for A_FaceTarget?
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!)
Re: Smooth monster turning for A_FaceTarget?
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.
Re: Smooth monster turning for A_FaceTarget?
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.
Re: Smooth monster turning for A_FaceTarget?
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.
Download Voxel Chibi Doom! and look at the ActorBase code, it should be in there.