Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

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:
  1. class QDGamePawn extends UDKPawn;
  2.  
  3. /** The pawn's light environment */
  4. var DynamicLightEnvironmentComponent LightEnvironment;
  5.  
  6. /**
  7. * returns default camera mode when viewing this pawn.
  8. * Mainly called when controller possesses this pawn.
  9. *
  10. * @param PlayerController requesting the default camera view
  11. * @return default camera view player should use when controlling this pawn.
  12. */
  13. simulated function name GetDefaultCameraMode( PlayerController RequestedBy )
  14. {
  15. return 'default';
  16. }
  17.  
  18. [COLOR=White]/** returns camera mode desired FOV */
  19. event float GetDesiredFOV( Pawn ViewedPawn )
  20. {
  21. if ( bFocusPointSet && (FocusPoint.CameraFOV > 0.f) && bFocusPointSuccessful )
  22. {
  23. return FocusPoint.CameraFOV;
  24. }
  25. return CurrentCamMode.GetDesiredFOV(ViewedPawn);
  26. }[/COLOR]
  27.  
  28. defaultproperties
  29. {
  30. Components.Remove(Sprite)
  31.  
  32. Begin Object Class=DynamicLightEnvironmentComponent Name=DynamicLightEnvironment
  33. bSynthesizeSHLight=TRUE
  34. bIsCharacterLightEnvironment=TRUE
  35. bUseBooleanEnvironmentShadowing=FALSE
  36. InvisibleUpdateTime=1
  37. MinTimeBetweenFullUpdates=.2
  38. End Object
  39. Components.Add(DynamicLightEnvironment)
  40. LightEnvironment=DynamicLightEnvironment
  41.  
  42. Begin Object Class=SkeletalMeshComponent Name=CharacterSkeletalMeshComponent
  43. bCacheAnimSequenceNodes=FALSE
  44. AlwaysLoadOnClient=true
  45. AlwaysLoadOnServer=true
  46. CastShadow=true
  47. BlockRigidBody=TRUE
  48. bUpdateSkelWhenNotRendered=false
  49. bIgnoreControllersWhenNotRendered=TRUE
  50. bUpdateKinematicBonesFromAnimation=true
  51. bCastDynamicShadow=true
  52. Translation=(Z=8.0)
  53. RBChannel=RBCC_Untitled3
  54. RBCollideWithChannels=(Untitled3=true)
  55. LightEnvironment=DynamicLightEnvironment
  56. bOverrideAttachmentOwnerVisibility=true
  57. bAcceptsDynamicDecals=FALSE
  58. AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
  59. bHasPhysicsAssetInstance=true
  60. TickGroup=TG_PreAsyncWork
  61. MinDistFactorForKinematicUpdate=0.2
  62. bChartDistanceFactor=true
  63. //bSkipAllUpdateWhenPhysicsAsleep=TRUE
  64. RBDominanceGroup=20
  65. Scale=1.075
  66. // Nice lighting for hair
  67. bUseOnePassLightingOnTranslucency=TRUE
  68. bPerBoneMotionBlur=true
  69. SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA'
  70. PhysAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
  71. AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
  72. End Object
  73. Mesh=CharacterSkeletalMeshComponent
  74. Components.Add(CharacterSkeletalMeshComponent)
  75. }
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:
  1. class QDGameThirdPersonCameraMode_Default extends GameThirdPersonCameraMode_Default;
  2.  
  3. [COLOR=White]/** Returns FOV that this camera mode desires. */
  4. function float GetDesiredFOV( Pawn ViewedPawn )
  5. {
  6. return 70.0;
  7. }[/COLOR]
  8.  
  9. defaultproperties
  10. {
  11. ViewOffset={(
  12. OffsetHigh=(X=-256,Y=56,Z=40),
  13. OffsetLow=(X=-320,Y=48,Z=56),
  14. OffsetMid=(X=-320,Y=48,Z=16),
  15. )}
  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
    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
    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).
    1. class QDGameThirdPersonCamera extends GameThirdPersonCamera;
    2.  
    3. /** returns camera mode desired FOV */
    4. event float GetDesiredFOV( Pawn ViewedPawn )
    5. {
    6. if ( bFocusPointSet && (FocusPoint.CameraFOV > 0.f) && bFocusPointSuccessful )
    7. {
    8. return FocusPoint.CameraFOV;
    9. }
    10. return CurrentCamMode.GetDesiredFOV(ViewedPawn);
    11. }
    12.  
    13. defaultproperties
    14. {
    15. [COLOR=White]ThirdPersonCamDefaultClass=class'QDGame.QDGameThirdPersonCameraMode_Default'[/COLOR]
    16. }
    Some reason it's not getting the Float from GameThirdPersonCameraMode_Default:
    1. class QDGameThirdPersonCameraMode_Default extends GameThirdPersonCameraMode_Default;
    2.  
    3. [COLOR=White]/** Returns FOV that this camera mode desires. */
    4. function float GetDesiredFOV( Pawn ViewedPawn )
    5. {
    6. return 70.0;
    7. }[/COLOR]
    8.  
    9. defaultproperties
    10. {
    11. ViewOffset={(
    12. OffsetHigh=(X=-256,Y=56,Z=40),
    13. OffsetLow=(X=-320,Y=48,Z=56),
    14. OffsetMid=(X=-320,Y=48,Z=16),
    15. )}
    16. }
Sign In or Register to comment.