UE3 - UT3 Cast Error from Mutate

  • 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.

Cockbite

New Member
Jul 28, 2009
21
0
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.uc(11) : Error, Cast from 'Pawn' to 'SelfDestruct' will always fail

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:

Cockbite

New Member
Jul 28, 2009
21
0
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.