Hi guys,
I'm trying to get the player to face an enemy automatically.. This works:
The problem is when I am targeting monsters with different heights. If I make something small the player wont face down at all, he will look straight forward. I've tried changing the collision cylinder and that didn't help. Can anyone tell me whether this is a fault with the code or with the Pawn itself?Code:function AutoTargeting() { //Trace information local Actor HitActor; local vector HitLocation; local vector HitNormal; //Position information local vector TraceDistance; local vector LookDistance; local Pawn Target; local Rotator ViewRotation; local Vector ViewLocation; local Rotator r; GetPlayerViewPoint(ViewLocation, ViewRotation); LookDistance = vector(ViewRotation) * 650; TraceDistance = ViewLocation + LookDistance; HitActor = Trace( HitLocation, HitNormal, TraceDistance, ViewLocation, true, vect(5,5,5) ); if ( Pawn(HitActor) == none) { Return; } if ( Pawn(HitActor) != none ) { Target = Pawn(HitActor); } r=Rotator(Target.Location-Pawn.Location); if ( Pawn(HitActor) != none) { SetRotation(r); } //ClientSetRotation(r); }
Thanks!



Reply With Quote



Bookmarks