Home Technical Talk

UDK Compile Error - Bad or Missing Expression

I've been following along with a tutorial I found for scripting a side scrolling game. This isn't the first error I've come across, but I've been able to handle them so far. However, my research isn't helping me fix this error:

"...QDGame\Classes\QDGamePawn.uc<21> : Error, Bad or missing expression for token: bFocusPointSet, in 'If'"

This error is referring to this little piece of script sitting in my QDGamePawn.uc:
class QDGamePawn extends UDKPawn;

/** The pawn's light environment */
var DynamicLightEnvironmentComponent LightEnvironment;

/**
 * returns default camera mode when viewing this pawn.
 * Mainly called when controller possesses this pawn.
 *
 * @param    PlayerController requesting the default camera view
 * @return    default camera view player should use when controlling this pawn.
 */
simulated function name GetDefaultCameraMode( PlayerController RequestedBy )
{
    return 'default';
}

[COLOR=White]/** returns camera mode desired FOV */
event float GetDesiredFOV( Pawn ViewedPawn )
{
    if ( bFocusPointSet && (FocusPoint.CameraFOV > 0.f) && bFocusPointSuccessful )
    {
        return FocusPoint.CameraFOV;
    }
    return CurrentCamMode.GetDesiredFOV(ViewedPawn);
}[/COLOR]

defaultproperties
{
  Components.Remove(Sprite)

  Begin Object Class=DynamicLightEnvironmentComponent Name=DynamicLightEnvironment
    bSynthesizeSHLight=TRUE
    bIsCharacterLightEnvironment=TRUE
    bUseBooleanEnvironmentShadowing=FALSE
    InvisibleUpdateTime=1
    MinTimeBetweenFullUpdates=.2
  End Object
  Components.Add(DynamicLightEnvironment)
  LightEnvironment=DynamicLightEnvironment

  Begin Object Class=SkeletalMeshComponent Name=CharacterSkeletalMeshComponent
    bCacheAnimSequenceNodes=FALSE
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    CastShadow=true
    BlockRigidBody=TRUE
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=TRUE
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    Translation=(Z=8.0)
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=DynamicLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=FALSE
    AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    //bSkipAllUpdateWhenPhysicsAsleep=TRUE
    RBDominanceGroup=20
    Scale=1.075
    // Nice lighting for hair
    bUseOnePassLightingOnTranslucency=TRUE
    bPerBoneMotionBlur=true
    SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
    PhysAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
    AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
  End Object
  Mesh=CharacterSkeletalMeshComponent
  Components.Add(CharacterSkeletalMeshComponent)
}
Nothing too daunting yet, just light environment and skeletal mesh with the beginings of a camera. I found this exact same piece of code in someone else's .uc, but it was not in Pawn. I've tried moving this code around and into my other .uc's but haven't had any luck. Either I get a compile error or it doesn't set my FOV (I can set it using console, though).

The event is calling to QDGameThirdPersonMode_Default.uc:
class QDGameThirdPersonCameraMode_Default extends GameThirdPersonCameraMode_Default;

[COLOR=White]/** Returns FOV that this camera mode desires. */
function float GetDesiredFOV( Pawn ViewedPawn )
{
    return 70.0;
}[/COLOR]

defaultproperties
{
    ViewOffset={(
       OffsetHigh=(X=-256,Y=56,Z=40),
       OffsetLow=(X=-320,Y=48,Z=56),
       OffsetMid=(X=-320,Y=48,Z=16),
    )}
}
Any help or advice would be much appreciated. I've been trying to understand each piece of code I'm using, so that I don't break it as I add more features later.

Replies

  • James Ordner
    Options
    Offline / Send Message
    The reason that you are getting that error is because you are trying to access variables that the pawn does not have access to. GetDesiredFOV() and the variables inside of the GetDesiredFOV() function are declared in GameThirdPersonCamera. This means that only the GameThirdPersonCamera class and any classes extending from that class have direct access to GetDesiredFOV() and those variables.

    If you wish to use GetDesiredFOV() from inside of your pawn class, you will need to reference an instance of GameThirdPersonCamera and call GetDesiredFOV() through your reference.
  • Fatman
    Options
    Offline / Send Message
    Thanks for the help. I see what you're saying and when I moved the GetDesiredFOV() over to my QDGameThirdPersonCamera the error went away, but it's still not setting the FOV for me when I play in browser (I can set it through console, so the rest is working).
    class QDGameThirdPersonCamera extends GameThirdPersonCamera;
    
    /** returns camera mode desired FOV */
    event float GetDesiredFOV( Pawn ViewedPawn )
    {
        if ( bFocusPointSet && (FocusPoint.CameraFOV > 0.f) && bFocusPointSuccessful )
        {
            return FocusPoint.CameraFOV;
        }
        return CurrentCamMode.GetDesiredFOV(ViewedPawn);
    }
    
    defaultproperties
    {
        [COLOR=White]ThirdPersonCamDefaultClass=class'QDGame.QDGameThirdPersonCameraMode_Default'[/COLOR]
    }
    
    Some reason it's not getting the Float from GameThirdPersonCameraMode_Default:
    class QDGameThirdPersonCameraMode_Default extends GameThirdPersonCameraMode_Default;
    
    [COLOR=White]/** Returns FOV that this camera mode desires. */
    function float GetDesiredFOV( Pawn ViewedPawn )
    {
        return 70.0;
    }[/COLOR]
    
    defaultproperties
    {
        ViewOffset={(
           OffsetHigh=(X=-256,Y=56,Z=40),
           OffsetLow=(X=-320,Y=48,Z=56),
           OffsetMid=(X=-320,Y=48,Z=16),
        )}
    }
    
Sign In or Register to comment.