Announcement

Collapse
No announcement yet.

Help with Camera Rig Script

Collapse
X
 
  • 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):

    https://forums.epicgames.com/udk/udk...tic-animations

    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:

    https://api.unrealengine.com/udk/Thr...riable%20Types

    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)

    camRig.PickupMesh.GetSocketWorldLocationAndRotation('cameraPosition1',camSocketPos,camSocketRot);

    Any help?
    Last edited by NIDAL NIJM GAMES; 07-03-2018, 10:25 PM.
    https://sites.google.com/view/udkultimate/


    #2
    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

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

    Comment


      #3
      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 (https://api.unrealengine.com/udk/Thr...riable%20Types), so I thought that the variable types were just like these:

      byte
      int
      bool
      float
      string
      constant


      But now I understood better.

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

      Cheers
      https://sites.google.com/view/udkultimate/

      Comment


        #4
        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;

        Super.BecomeViewTarget(PC);

        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
        UTPC.SetBehindView(true);
        SetMeshVisibility(UTPC.bBehindView);
        }
        }
        }

        defaultproperties
        {
        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?
        https://sites.google.com/view/udkultimate/

        Comment


          #5
          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.

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

          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
          Super.DetachFromController();
          Super.StopFiring();
          GroundSpeed=0;

          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.
          UTPlayerController(localplayer).IgnoreLookInput(true);
          UTPlayerController(localplayer).IgnoreMoveInput(true);
          UTPlayerController(localplayer).ConsoleCommand("God");
          //(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
          UTPlayerController(localplayer).SetRotation(UTPawn(EventInstigator.Pawn).Rotation);
          UTPlayerController(localplayer).PlayCameraAnim(CameraAnim'knife.Camera1Anim',,,,,false);
          //UTPlayerController(localplayer).ClientSpawnCameraLensEffect(class'ChainsawCameraBlood');

          //this is a timer that will call for the function to return player movement back to normal
          //it has the duration of the animation
          SetTimer(3.04,false,nameof(ReturnPlayerNormal));

          }

          //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.SetActorAnimEndNotification(true);
          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.SetActorAnimEndNotification(true);
          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
          SetTimer(3.04,false,nameof(KillEnemy));

          // 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;
          }
          https://sites.google.com/view/udkultimate/

          Comment


            #6
            Try this, not sure if it will work.

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

            Comment


              #7
              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.

              Cheers.

              https://sites.google.com/view/udkultimate/

              Comment

              Working...
              X