![]() |
|
|
#1 | |
|
Registered User
Join Date: Jul. 28th, 2009
Posts: 21
|
[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.
Quote:
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 by Cockbite; 16th Jul 2010 at 09:20 PM. Reason: Problem Solved |
|
|
|
|
|
|
#2 |
|
Typecasting seems to take precedence over function calls. Your code really tries to typecast that Pawn reference to your mutator class.
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak | Unreal Wiki | Liandri Archives Everything you ever wanted to know about replication | UnrealScript security considerations <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort <TNSe> nono <TNSe> its always funny to find code a week later you dont even remember writing <Pfhoenix> what's worse is when you have a Star Wars moment <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!" |
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Jul. 28th, 2009
Posts: 21
|
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 |
|
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.
__________________
Unreal Development Kit Game Programming with UnrealScript: Beginner’s Guide Stubborn Horse Studios - Angel Mapper To have said goodbye to things! |
|
|
|
|
|
|
#5 |
|
Registered User
Join Date: Jul. 28th, 2009
Posts: 21
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|