Announcement

Collapse
No announcement yet.

Help with Slomo Effect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Slomo Effect

    Hello guys!

    It's me here annoying again

    I added a cool slomo effect whenever the player perform a headshot on the enemy.

    The effect is very simple, it's basically detect the hit bone on the pawn takedamage event (it runs on the enemy pawn class):

    Code:
        //this variable is to identify the hit location
        local name HitBone;
        HitBone = Mesh.FindClosestBone(HitLocation);
    
        //this statement will check if the enemy was attacked by bullet weapons to play the hitbones animations and death
        //we are isolating the hitbones detection only to bullet weapons
        //also we don't need Headhosts nor hit reaction animations whenever using RPG7
        if (DamageType != class'UTDmgType_AIKnife' && DamageType != class'UTDmgType_RPG7')
        {
    
          //headshot//////////////////////////////////////////////////////
          //we also want that headshot effect be triggered only by players (p1 and p2) and not Bots   
          if(!EventInstigator.PlayerReplicationInfo.bBot)
          {
    
            if(HitBone == 'b_Neck' || HitBone == 'b_Head')
            {    
    
             TopHalfAnimSlot.StopCustomAnim(0.15);
    
            `Log("Headshot");
    
             HeadShotCount = true;
    
             //this function will play the flash animation headshot icon and slomo effect/////////////////
             ForEach LocalPlayerControllers(class'PlayerController', localPlayer)
             {
             SetTimer(0.15,false,nameof(StartSlomo));
             SetTimer(0.35,false,nameof(FinishSlomoHeadshot));
             }      
    
             //this function will play the flash animation headshot icon and slomo effect/////////////////
             Super.Suicide();
    
            }
    
          }
          //headshot//////////////////////////////////////////////////////
    So I set a small timer to sent the pawn to the slomo function:

    Code:
    //this function will turn on slomo for headshots
    simulated function StartSlomo()
    {
           WorldInfo.Game.SetGameSpeed(0.25);
           ClearTimer();
    }
    then after one second (because the slomo effect slows the time), I send the pawn to the finish slomo function:

    Code:
    //this function will turn off slomo
    simulated function FinishSlomoHeadshot()
    {
           local Playercontroller localplayer;
    
           WorldInfo.Game.SetGameSpeed(1);
    
           ForEach LocalPlayerControllers(class'PlayerController', localPlayer)
           {
           UTPlayerController(localplayer).ConsoleCommand("HeadshotIconAnimStart");
           }    
           ClearTimer();
    }
    Everything is working perfectly, however, I realized a bug, that happens only with keyboard on PC, but if I use a gamepad (xbox360 controller), this bug does not happen (also it does not happen on consoles PS3 Xbox360). This bug only happens with a keyboard on PC.

    The bug is that if whenever the slomo effect begins, the player is pressing any of the moving keys (W,A,S,D), the player pawn continues running to the direction the button was pressed. In example, if whenever the slomo effect began I was running left (pressing A), the player pawn continues to walk left forever, and only stops if I press the key another time.

    Any help?

    I like the slomo effect, it feels kinda bullet time, but if I can't solve this problem, I will remove it (slomo effect).

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


    #2
    if ( bIsInSlomoState )
    return;
    //do not move on the process move function playercontroller

    Or make a new state on playerController extending player move

    SlowMo state processMove() doing nothing.

    Good like my friend and pieeeeeeeeeeeeece : D

    I can specifiy further. But i would like a copy of your game for fun , PURELY FUN.
    Some cool unreal projects you may like!


    Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

    Download the demo Download the demo
    external link Dropbox DropBox

    Become a c++ Professional now C++ Networking Tutorial

    Comment


      #3
      Hello @Neongho

      Thanks man for the tip.

      Ok, I understood now. But I will try also to disable player input during that one second on which the slomo effect happens.

      Here is the video showcasing the slomo effect, begin on 05:46:

      https://www.indiedb.com/games/fursan...mies-ai-update

      I plan (hope) untill march release the first episode of my game, with a lot of content, including split screen multiplayer, with many game modes

      Cheers my friend!
      https://sites.google.com/view/udkultimate/

      Comment


        #4
        Try Cleartimer('timername'); instead Cleartimer(); ?
        Provisional blog: http://cobaltudk.blogspot.com.es/
        Videos: https://www.youtube.com/user/cobaltudk
        Facebook: https://www.facebook.com/babylonprojectgame/

        Comment


          #5
          Originally posted by CobaltUDK View Post
          Try Cleartimer('timername'); instead Cleartimer(); ?
          Hello man, how are you

          Thanks for trying to help me.

          I think I already discovered the problem.

          This line of code is causing the bug on which the player continues moving indefinetely if the player is pressing one of the move keys whenever the slomo effect begins.

          This line of code causes this bug:

          Code:
          UTPlayerController(localplayer).ConsoleCommand("HeadshotIconAnimStart");
          I think that whenever the enemy pawn casts the localplayer and tries to run a console command (any console command), this bug happens.

          This exec function HeadshotIconAnimStart is just a function I created inside UTGFxHudWrapper class to show the headshot icon animation:

          Code:
          //function to show headshot icon animation////////////////////////////////////////////////////
          exec function HeadshotIconAnimStart()
          {
            if ( HeadshotIconHUD == none )
                 HeadshotIconHUD = new(PlayerOwner) class'UTGFxTweenableMoviePlayer';
          
            HeadshotIconHUD.MovieInfo = SwfMovie'gameplay_icons.udk_headshot';
            HeadshotIconHUD.bDisplayWithHudOff = true;
            HeadshotIconHUD.bEnableGammaCorrection = false;
            HeadshotIconHUD.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
            HeadshotIconHUD.SetTimingMode(TM_Real);
            HeadshotIconHUD.Start();
            HeadshotIconHUD.SetViewScaleMode(SM_NoScale);
            HeadshotIconHUD.SetAlignment(Align_Center);
            HeadshotIconHUD.Advance(0);
            setTimer(1.00, false, 'HeadshotIconAnimEnd');
          }
          
          function HeadshotIconAnimEnd()
          {
            HeadshotIconHUD.Close();
            ClearTimer();
          }
          //function to show headshot icon animation////////////////////////////////////////////////////
          However, If I show this flash movie icon animation in kismet, using GFXMovieOpen node, that bug does not happen.

          By the way, the bug is not because the slomo, it happenned even without slomo, it has to do with the loading of that flash animation and casting the local player to run a console command.

          Any ideas to solve it (besides doing everything in kismet)?

          This is a minor bug because the player hardly will be able to do a headshot while running (the enemies move a lot). However, as a game developer, you need to think on all possible scenarios, right?

          EDIT I HAVE A LOT OF OTHERS EXEC FUNCTION, I TESTED NOW, AND ONLY THAT EXEC FUNCTION TO LOAD FLASH ICON (IN UTGFXHUDWRAPPER) CAUSES THE PROBLEM.

          I tested now an exec function inside my player pawn, and the bug did not happen.
          Last edited by NIDAL NIJM GAMES; 02-03-2020, 04:52 PM.
          https://sites.google.com/view/udkultimate/

          Comment


            #6
            Hello guys, found the solution. What matter is that it works the way I want.

            To give my game some kinda variation, I am creating many game modes, besides campaign. Two of these game modes are Heashots and BlowThemUp.

            In headshots the player needs to do a minimum ammount of headshots to complete the mission. So, even though the enemy pawn detects headshot (one headshot he dies), I decided to show the headshot icon only on this mode, as it will have no use on campaign mode, in example.

            So whenever I do something specific for a map (because the map will contain all gameplay rules, done in kismet), I can do all in kismet, both the slomo effect and load a gfx movie (headshot icon) in kismet instead of loading from UTGFXHudWrapper using an exec function, as it is only this what was causing the bug.

            Now another doubt, how can I set SetViewScaleMode(SM_NoScale) for the FlashMovie loaded in kismet throught openGFXMovie?
            https://sites.google.com/view/udkultimate/

            Comment


              #7
              Already solved it. Just on the flash file I add a new layer for action script, and add this small code:

              Code:
              Stage.scaleMode = "noScale"
              Thanks
              https://sites.google.com/view/udkultimate/

              Comment

              Working...
              X