Slowly face enemy?
Blitz3D Forums/Blitz3D Programming/Slowly face enemy?
| ||
this code should be for my ally that is an A.I. i want my ally to slowly point (not a snappy pointing) to the direction enemy if the enemy is with less than 20 units away from him... how do i do this? an algorithm will do :) it's in 3D |
| ||
If it is an humanoid, you can use a combination of entityyaw() (to check the humanoid orientation related to the other humanoid), then turn it with turnentity() or rotate it with rotateentity()... |
| ||
The following will do the job. Play with the MinTurn to get the turning speed right. Function TurnToFace( SourceEntity , DestinationEntity, MinTurn# ) Local DY# = DeltaYaw( SourceEntity, DestinationEntity ) If ABS( DY ) > MinTurn DY = MinTurn Turnentity AIentity, 0, DY, 0 End Function |