1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

UE3 - UT3 Cast Error from Mutate

Discussion in 'Programming' started by Cockbite, Jul 9, 2010.

  1. Cockbite

    Cockbite New Member

    Joined:
    Jul 28, 2009
    Messages:
    21
    Likes Received:
    0
    [Solved] Cast Error from Mutate

    This code is supposed to be a simple Self Destruction mutator. The idea is you just type "Mutate Explode", and then you go out with a bang. My problem is that I'm getting an error that I don't know how to fix.

    SelfDestruct() asks for a Pawn, and I would assume that 'Sender.Pawn' is a pawn, so I don't quite see what the problem is. Does anyone know how to make this work?

    Code:
    Class SelfDestruct extends UTMutator;
    
    var PlayerController playerController;
    var Controller InstigatorController;
    
    function Mutate(string MutateString, PlayerController Sender)
    {
    	Super.Mutate(MutateString, Sender);
    	if (MutateString ~= "Explode" && Sender != None && Sender.Pawn != None)
    	{
    		SelfDestruct(Sender.Pawn);
    	}
    }
    
    function SelfDestruct(Pawn P)
    {
    	local UTProj_HeroRedeemer Proj;
    	Proj = Spawn(class'UTProj_HeroRedeemer', InstigatorController,, P.Location);
    }
     
    Last edited: Jul 16, 2010
  2. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    Typecasting seems to take precedence over function calls. Your code really tries to typecast that Pawn reference to your mutator class.
     
  3. Cockbite

    Cockbite New Member

    Joined:
    Jul 28, 2009
    Messages:
    21
    Likes Received:
    0
    I'm still not sure I understand what you said, but I figured out the problem. The error here is that I made a function called "SelfDestruct" when the game already has a native SelfDestruct function. This apparently confuses the game and makes it angry. Once I changed the name of my function to "BlowUp", it works perfectly like I intended.
     
  4. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    No, it was because the class name is SelfDestruct, so it thought you were trying to cast the Sender.Pawn to a SelfDestruct class type.
     
  5. Cockbite

    Cockbite New Member

    Joined:
    Jul 28, 2009
    Messages:
    21
    Likes Received:
    0
    Okay, I get it now. So, I can call my function SelfDestruct if I change the script name.
     

Share This Page