![]() |
|
|
#1 |
typecasting ;(
How would I get my custom PlayerController class from Pawn?
Pawn.Controller(nsfplayer).blah blah? Controller(nsfplayer.pawn).blah blah? I'm lost, I would love some help
|
|
|
|
|
|
|
#2 |
|
You've got it flipped. it's:
nsfplayer(Pawn.Controller).foo; nsfplayer(Controller).foo; etc. |
|
|
|
|
|
|
#3 |
|
Typecasting always works like this:
ClassToTypecastTo(ObjectToTypecast).PropertyToAccess or ClassToTypecastTo(ThingToGetObjectFrom.ObjectToTypecast).PropertyToAccess
__________________
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!" |
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Jul. 24th, 2003
Posts: 47
|
Wormbo that's the best explanation of typecasting ever
|
|
|
|
|
|
#5 | |
|
Quote:
I got two classes. One is SC_Crystal and the other SC_Blue_Crystal. The blue crystal one is a subclass of crystal. and two references. one called just crystal, and the other blue_crystal. no i take a for loop through the navigiationpointlist and check if there is one of my crystals or blue ones Code:
[...] // NP is the reference to NavigationPoint // if...found crystal -> works Crystal = SC_Crystall(NP); // if...found blue crystal --> works Blue_Crystal = SC_Blue_Crystal(NP); // if found blue crystal (another bsp) -> wont works Blue_Crystal = SC_Crystal(NP); [...] Just want to know why. Evil |
||
|
|
|
|
|
#6 |
|
The cast itself works well, the compiler moans about a different problem: You can only assign objects of the same class or a sbuclass to a variable.
Your Crystal variable can hold any SC_Crystal and any subclass of it, like SC_Blue_Crystal, but you can't assign an SC_Crystal to the Blue_Crystal variable because it's not a subclass of SC_Blue_Crystal.
__________________
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!" |
|
|
|
|
|
|
#7 |
|
ok, thats clear to me. but in the first tries i also tried to set Crystal = SC_Blue_Crystal(NP) and it even gives me an access none. weird, isn´t it?
|
|
|
|
|
|
|
#8 | |
|
Quote:
__________________
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!" |
||
|
|
|
|
|
#9 |
|
Hmm, k. And thx for explenation.
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|