10
\$\begingroup\$

So, to be brief, I'm trying to teleport a pawn when it's struck by a projectile (or damaged by any weapon in my game.)

Right now, I'm trying to just call Pawn.SetLocation in the projectile's ProcessTouch. That's a problem because ProcessTouch will hit any actor, not just a pawn. Additionally, any attempts to check the ProcessTouch's "Actor Other" throws errors.

I've tried a bunch of solutions (including making a event TakeDamage in the Pawn controller class,) but to no avail.

    simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal)
    {
         if (Other != Instigator)
         {
              //This is where the Other.TakeDamage goes if we are using a traditional gun.
              if (Other == Pawn);
              {
                   Other.SetLocation(0,0,0);
              }
         }
    Destroy;
    }

This code complains that Pawn's a bad expression. How else should I check actor type here?

\$\endgroup\$
0
\$\begingroup\$

I think you miss to cast your pawn as :

if( myDesiredClass(Other) != none)

Check it and give me feedback if you face any new problem.

\$\endgroup\$
0
\$\begingroup\$

In my opinion you could either do it by checking the class

Other.class == class'Pawn'

or by casting and checking it whether it's None or not

Pawn(Other) != None

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.