Announcement

Collapse
No announcement yet.

(solved)distance from player to pawn when shot.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    (solved)distance from player to pawn when shot.

    im trying to get the distance from the player to the pawn he shoots it.im using the take damage function in the pawn as below but it always returns the distance from the players spawn point to the pawn and not the current distance.

    Code:
    event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
            local int OldHealth;
    	
    
    	local float enemyDist;
    
    
                   
            enemyDist = VSize( Location - EventInstigator.Location );
    
                `log("longshot" @  enemydist);
            
                  if(enemydist <= 1500)
    	               {
                                      `log("shot" @  enemydist);
    
                    	}
    }

    #2
    Controller Location's do not update when you move the Pawn. So the Controller actors location will ALWAYS be the same as it's spawn location, unless it is altered elsewhere. Why don't you grab the location of the EvenInstigator's Pawn instead?

    Code:
    if ( EventInstigator != None && EventInstigator.Pawn != None ) {
        enemyDist = VSize( Location - EventInstigator.Pawn.Location );
    
        log("longshot" @  enemydist);
    
         if ( enemydist <= 1500 ) {
              `log("shot" @  enemydist);
          }
    }

    Comment


      #3
      works perfectly thanks.youve made me very happy.

      Comment

      Working...
      X