No announcement yet.

Help with Camera Rig Script

  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Camera Rig Script

    Hello guys, I am trying to implement this code on my project to have some cool camera animations in game (like Gears of War Executions):

    However, I am having problems on compiling the code, mainly on the declaration of the variables:

    //An instance of the CameraRig class so we can spawn the camera in game
    var CameraRig camRig;

    Whenever I first compiled the code, it gave me a error message of variable type not recognized. So searching here:

    I have seen that this type of variable "CameraRig" does not exist, so i tried like

    var Actor camRig;
    var Object camRig;
    var SkeletalMesh camRig;

    and others, however I receive the error message: Unrecognized member PickupMesh in class 'actor', and so on, because down on the code there is a command like this:

    //Get the cameraPosition socket location from the camera rig mesh

    if (cameraNumber == 1)


    Any help?
    Last edited by NIDAL NIJM GAMES; 07-03-2018, 10:25 PM.

    Hey udkultimate it looks like you're running into some problems with some of the concepts in object-oriented programming.

    What you're trying to do is make an actor (which in UnrealScript terminology is just a special kind of object). A class is like a blueprint that shows the game how to make a specific kind of actor. You want to make a class called CameraRig, and then in your Pawn class, you want to make a CameraRig actor called camRig.

    When the compiler tells you that CameraRig does not exist, it's because it can't find a class that tells it what a CameraRig is. Did you make a new file called CameraRig.uc? And then after making the file did you add it to your project? That's the file that will tell the game what a CameraRig is. In that file, you need to paste all the code beginning with

     class CameraRig extends Actor 	placeable;
    Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.


      Oh man, how stupid I am

      Off course, now I understood, I changed the name of the class CameraRig.uc to killCam.uc

      I did not know that you can have a custom class as a variable type in Unreal Script.

      I was reading on udn about variable types (, so I thought that the variable types were just like these:


      But now I understood better.

      Thanks man, trully thanks, I will fix this now.



        Hello guys,

        Sorry for being annoying

        I have playing with this custom camera rig, however, I did not like it, it is so buggy, sometimes the camera gets weird movements, sometimes the camera gets spawned on the map origin (0,0,0).

        So I think the best and easiest way to do custom camera animation for these stealth kills is indeed creating a camera animation in matinee, then exporting it as cameraAnim.

        Also I think I know how to solve the problem with the camera initial rotation, which needs to match the matinee camera. What I need is just to be able to reset the player view to the initial camera rotation whenever the player spawns on the world.

        I am using behindview with some offsets:

        //override to make player mesh visible by default
        simulated event BecomeViewTarget( PlayerController PC )
        local UTPlayerController UTPC;


        if (LocalPlayer(PC.Player) != None)
        UTPC = UTPlayerController(PC);
        if (UTPC != None)
        //set player controller to behind view and make mesh visible
        //since we are not using the Pawn.CalcCamera() function so camera animations (chainsaw execution, i.e) will work normally

        CamOffset = (X=6, Y=15, Z=-42);
        //CamOffset = (X=6, Y=15, Z=-28);
        //x -> distance from camera
        //y -> horizontal position
        //z -> vertical position

        So this initial rotation on the player camera is exactly the same rotation of the matinee's camera.

        So I need to know how to implement in unreal script a function to reset the player view rotation to the initial rotation before beginning the knife kill sequence. In example if the player is aproaching the enemy from behind, and if before he begins the knife kill sequence, he looks at the sky, so I need that the camera comes back to the initial rotation (player looking forward), so this way it will match the matine's camera.

        So how can I do this?


          Hello guys.

          WOW, after many days and headaches, and with help of one friend of mine from outside this forum, finally I was able to solve the problem with the setting the initial camera rotation to match with the matinee camera initial rotation.

          I just needed to set the player controller rotation the same as the player pawn rotation before playing the camera animation.


          This is my knife kill script (this is an enemy pawn script):

          //all the animation will be played inside the TakeDamage Event
          event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
          local int OldHealth;
          //this variables will be used to access player controller and play the camera animation on the player controller
          local Playercontroller localplayer;

          //this statement will check if the enemy was attacked by the knife weapon
          if (DamageType == class'UTDmgType_Knife')

          //this will freeze the enemy pawn

          if(vector(UTPawn(EventInstigator.Pawn).Rotation) dot vector(Rotation) >= 0) // i.e., they're facing the same direction

          // Do back attack animation///////////////////////////////////////////////////////////////////////////////////////////////////

          ForEach LocalPlayerControllers(class'PlayerController', localPlayer)

          //this will freeze the player movement and other cool effects like slo-mo and invencibility.
          //(bool bInCinematicMode, bool bHidePlayer, bool bAffectsHUD, bool bAffectsMovement, bool bAffectsTurning, bool bAffectsButtons)
          UTPlayerController(localplayer).SetCinematicMode (true, false, false, true, false, true);

          //this is the function to play the camera animation and blood splat effect

          //this is a timer that will call for the function to return player movement back to normal
          //it has the duration of the animation


          //this will play the mesh ripp appart sound
          //PlaySound(SoundCue'WP_GOW.Sounds.knifeDeath_Cue', false, true, true, vect(0,0,0), false);

          //this statement will play the knife kill animation back on the player
          UTPawn(EventInstigator.Pawn).FullBodyAnimSlot.PlayCustomAnim('knife_kill_1_player', 1.0, 0.25, 0.25, false, false);

          //this statement will play the knife kill animation back on the enemy pawn
          FullBodyAnimSlot.PlayCustomAnim('knife_kill_1_enemy', 1.0, 0.25, 0.25, true, false);

          //this is a timer that will call for the function deathsequence and come back to normal
          //it has the duration of the animation

          // Do back attack animation///////////////////////////////////////////////////////////////////////////////////////////////////


          else // i.e., they're facing each other

          // Do front attack animation///////////////////////////////////////////////////////////////////////////////////////////////////

          // Do front attack animation///////////////////////////////////////////////////////////////////////////////////////////////////



          //this is the code for take damage itself
          OldHealth = Health;
          AccumulateDamage += Damage;
          Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
          AccumulateDamage = AccumulateDamage + OldHealth - Health - Damage;


            Try this, not sure if it will work.

            UTPlayerController(localplayer).SetRotation(UTPlayerController(localplayer).Pawn.Rotation );


              Originally posted by gamepainters View Post
              Try this, not sure if it will work.

              UTPlayerController(localplayer).SetRotation(UTPlayerController(localplayer).Pawn.Rotation );
              Hello dude, thanks for your comment, however, it worked (UTPlayerController(localplayer).SetRotation(UTPawn(EventInstigator.Pawn).Rotation)), I just liked to share my script with people here, maybe it can be usefull for someone.