From 2bd7723269429ace976ad83ee7785942b042ceee Mon Sep 17 00:00:00 2001 From: Sara Montecino Date: Sat, 12 Nov 2022 00:18:28 -0800 Subject: [PATCH] Hold shoot for auto fire --- Content/PlayerPawn_BP.uasset | Bin 100816 -> 100865 bytes PresidentsBrigade.sln | 90 ++++++++++++------------ Source/PresidentsBrigade/BasePawn.cpp | 22 ++++++ Source/PresidentsBrigade/BasePawn.h | 15 ++++ Source/PresidentsBrigade/PlayerPawn.cpp | 3 +- todo.txt | 2 +- 6 files changed, 85 insertions(+), 47 deletions(-) diff --git a/Content/PlayerPawn_BP.uasset b/Content/PlayerPawn_BP.uasset index b3003fb210437b3c7dc970de65b625340dccbede..346dde704c1969a3550ee848da7293395aa48dcc 100755 GIT binary patch delta 4003 zcmcImdr*{B6#otavPQMb?#J%3Yl(t@!Gt!Frh_wFdK=#a;)P_{2ZNLQH&@Sn-pal(jJtf?TP}(TP7>Y z6#Nw?gJSwA#4@q#^(DTPU5Z)ed4OTZ69Lqi)-V`fPP zf7s&Y@>rJPV@ScL4fcvBs|vBheogKasDP{ZW;Ht%VoTnK5yhJ5B1#I;D~NcOcxl^2 z@{ee%BtDR6F$)Ky?v6CmXoF(5LVG%lw#mhW6GWmUEoQwM?yUCw%4nNgO=ywlOyXr0 zdr1}Nbc*;<|y-A{MLa)f$&V zxew{=2`*tFTdn5!RTT2xTClTtn1rp3RW}kcMhpw_w^(>+&V=p~;PEvOgHV5V(qv+v zhU(Rq2oi+!1o11`&Cv8vS$g3phAe}ncY-<1vF7!t7rBbJBPgxNGLJ9=<_HbsM6dSN6K`?TQSXr3fEGAKglDJuI!$N%wQxefly1L)PBC8g` z`Z3hWP&<3mrdQ=Sh-6OEyDOUdZGHVVI1vXCef7z3Cb8CVLm@<~GGU>zhzG7No>mC)(8cQ!k=W!? zx)17k(Oz6~YuXhdK~i~uK+RfdZx=!kY~zDPV1Y)yvk0PR$heU%XNqjLthF+Q40nrv zb)5KKFT8uU-TClWipP;{xtF*9-rdo0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7{O^wRU2VX8f!!@?f{Yo$7~^`{jdOz!(*;ip%ps+s%J zeIjnA6yB=1Pj=QqT6iOLs21cUfh(`(K0V~9FPs}lT=0PN^ZEQWR{be!_$(wXcQGx+ z99&P2_^^6C^fMnM(t$0oCi-;__0Tm9;IVJu(}!k=o~{EKwa?YTOHe^AKCq63>0HA@ zOBV*|QnO*0MHBr7pDw4r`Jm?U z;`*mSi)&2dNO7sq%mOH)7aKF&A`3J*=cRwuZ~Z@olg)I!B~HF9Ccz z>9iJ@XJ5<#QDs5pu=f9z!$Dz;_hBp9a;h%*;-nwfW%b^0c$R;0ImN@i_UZiAFfm~b z54S=#ET!3Puz{BDg0oOUr?f*Vyh{sq!!~+oClucoCGCQj2lutZ0Wf5P`8!}W(5r2* z(2&u>cF3g1+aOk7Ic_Zbw5Zmi=>B{%TE*|r@7%XXe diff --git a/PresidentsBrigade.sln b/PresidentsBrigade.sln index 9e27c43..954887a 100755 --- a/PresidentsBrigade.sln +++ b/PresidentsBrigade.sln @@ -7,9 +7,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{94A6C6 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Games", "Games", "{8E2F6A87-1826-34F4-940C-CC23A48F9FE4}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PresidentsBrigade", "Intermediate\ProjectFiles\PresidentsBrigade.vcxproj", "{97946AF8-2BBD-45DF-B560-04E9007DCB1A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PresidentsBrigade", "Intermediate\ProjectFiles\PresidentsBrigade.vcxproj", "{96B177F0-8EDF-4729-A78F-BAD24CB85C00}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UE4", "Intermediate\ProjectFiles\UE4.vcxproj", "{7B9D3087-59A5-43EF-B77B-4DBA855467B6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UE4", "Intermediate\ProjectFiles\UE4.vcxproj", "{79A8FA76-49BB-457C-B380-F831AAAAD3DE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizers", "Visualizers", "{1CCEC849-CC72-4C59-8C36-2F7C38706D4C}" ProjectSection(SolutionItems) = preProject @@ -35,53 +35,53 @@ Global Shipping|Win64 = Shipping|Win64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame Editor|Android.ActiveCfg = Invalid|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame Editor|Win32.ActiveCfg = Invalid|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame Editor|Win64.ActiveCfg = DebugGame_Editor|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame Editor|Win64.Build.0 = DebugGame_Editor|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Android.ActiveCfg = Android_DebugGame|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Android.Build.0 = Android_DebugGame|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Win32.ActiveCfg = DebugGame|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Win32.Build.0 = DebugGame|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Win64.ActiveCfg = DebugGame|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.DebugGame|Win64.Build.0 = DebugGame|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development Editor|Android.ActiveCfg = Invalid|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development Editor|Win32.ActiveCfg = Invalid|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development Editor|Win64.ActiveCfg = Development_Editor|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development Editor|Win64.Build.0 = Development_Editor|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Android.ActiveCfg = Android_Development|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Android.Build.0 = Android_Development|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Win32.ActiveCfg = Development|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Win32.Build.0 = Development|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Win64.ActiveCfg = Development|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Development|Win64.Build.0 = Development|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Android.ActiveCfg = Android_Shipping|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Android.Build.0 = Android_Shipping|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Win32.ActiveCfg = Shipping|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Win32.Build.0 = Shipping|Win32 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Win64.ActiveCfg = Shipping|x64 - {97946AF8-2BBD-45DF-B560-04E9007DCB1A}.Shipping|Win64.Build.0 = Shipping|x64 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame Editor|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.DebugGame|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development Editor|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Development|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Shipping|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Shipping|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 - {7B9D3087-59A5-43EF-B77B-4DBA855467B6}.Shipping|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame Editor|Android.ActiveCfg = Invalid|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame Editor|Win32.ActiveCfg = Invalid|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame Editor|Win64.ActiveCfg = DebugGame_Editor|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame Editor|Win64.Build.0 = DebugGame_Editor|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Android.ActiveCfg = Android_DebugGame|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Android.Build.0 = Android_DebugGame|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Win32.ActiveCfg = DebugGame|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Win32.Build.0 = DebugGame|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Win64.ActiveCfg = DebugGame|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.DebugGame|Win64.Build.0 = DebugGame|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development Editor|Android.ActiveCfg = Invalid|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development Editor|Win32.ActiveCfg = Invalid|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development Editor|Win64.ActiveCfg = Development_Editor|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development Editor|Win64.Build.0 = Development_Editor|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Android.ActiveCfg = Android_Development|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Android.Build.0 = Android_Development|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Win32.ActiveCfg = Development|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Win32.Build.0 = Development|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Win64.ActiveCfg = Development|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Development|Win64.Build.0 = Development|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Android.ActiveCfg = Android_Shipping|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Android.Build.0 = Android_Shipping|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Win32.ActiveCfg = Shipping|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Win32.Build.0 = Shipping|Win32 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Win64.ActiveCfg = Shipping|x64 + {96B177F0-8EDF-4729-A78F-BAD24CB85C00}.Shipping|Win64.Build.0 = Shipping|x64 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame Editor|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.DebugGame|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development Editor|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Development|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Shipping|Android.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Shipping|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32 + {79A8FA76-49BB-457C-B380-F831AAAAD3DE}.Shipping|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {7B9D3087-59A5-43EF-B77B-4DBA855467B6} = {94A6C6F3-99B3-346E-9557-ABF9D4064DBD} - {97946AF8-2BBD-45DF-B560-04E9007DCB1A} = {8E2F6A87-1826-34F4-940C-CC23A48F9FE4} + {79A8FA76-49BB-457C-B380-F831AAAAD3DE} = {94A6C6F3-99B3-346E-9557-ABF9D4064DBD} + {96B177F0-8EDF-4729-A78F-BAD24CB85C00} = {8E2F6A87-1826-34F4-940C-CC23A48F9FE4} EndGlobalSection EndGlobal diff --git a/Source/PresidentsBrigade/BasePawn.cpp b/Source/PresidentsBrigade/BasePawn.cpp index 032b0ea..7f8d42f 100755 --- a/Source/PresidentsBrigade/BasePawn.cpp +++ b/Source/PresidentsBrigade/BasePawn.cpp @@ -85,6 +85,15 @@ void ABasePawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); + /* + * Auto-fire. + */ + shoot_time_elapsed += DeltaTime; + if (shooting_enabled && shoot_time_elapsed > fire_rate_s) + { + shoot(); + } + /* * Handle death. */ @@ -122,6 +131,17 @@ void ABasePawn::update_yaw_y(float y_component) yaw.y_component = y_component; } +void ABasePawn::start_shooting() +{ + shooting_enabled = true; + shoot(); +} + +void ABasePawn::stop_shooting() +{ + shooting_enabled = false; +} + void ABasePawn::shoot() { FVector player_location = player_mesh->GetComponentLocation(); @@ -141,6 +161,8 @@ void ABasePawn::shoot() rotator, spawnParameters ); + + shoot_time_elapsed = 0; } void ABasePawn::handle_death() diff --git a/Source/PresidentsBrigade/BasePawn.h b/Source/PresidentsBrigade/BasePawn.h index 7656888..1ff7a8d 100755 --- a/Source/PresidentsBrigade/BasePawn.h +++ b/Source/PresidentsBrigade/BasePawn.h @@ -27,6 +27,8 @@ public: virtual void handle_move_forward(float axis); virtual void update_yaw_x(float x_component); virtual void update_yaw_y(float y_component); + virtual void start_shooting(); + virtual void stop_shooting(); virtual void shoot(); virtual void handle_death(); protected: @@ -101,6 +103,19 @@ protected: UPROPERTY(EditAnywhere, Category = "Attack") int32 max_health; + UPROPERTY(EditAnywhere, Category = "Attack") + float fire_rate_s; + + /** + * Shooting enabled; + */ + bool shooting_enabled; + + /** + * Time elapsed since last shot. + */ + float shoot_time_elapsed; + /** * Current health for character. */ diff --git a/Source/PresidentsBrigade/PlayerPawn.cpp b/Source/PresidentsBrigade/PlayerPawn.cpp index ffc7499..2d93307 100755 --- a/Source/PresidentsBrigade/PlayerPawn.cpp +++ b/Source/PresidentsBrigade/PlayerPawn.cpp @@ -32,7 +32,8 @@ void APlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen PlayerInputComponent->BindAxis("MoveRight", this, &ABasePawn::handle_move_right); PlayerInputComponent->BindAxis("YawXUpdate", this, &ABasePawn::update_yaw_x); PlayerInputComponent->BindAxis("YawYUpdate", this, &ABasePawn::update_yaw_y); - PlayerInputComponent->BindAction("Shoot", EInputEvent::IE_Pressed, this, &ABasePawn::shoot); + PlayerInputComponent->BindAction("Shoot", EInputEvent::IE_Pressed, this, &ABasePawn::start_shooting); + PlayerInputComponent->BindAction("Shoot", EInputEvent::IE_Released, this, &ABasePawn::stop_shooting); PlayerInputComponent->BindAction("Boost", EInputEvent::IE_Pressed, this, &APlayerPawn::boost); PlayerInputComponent->BindAction("Boost", EInputEvent::IE_Released, this, &APlayerPawn::reset_boost); } diff --git a/todo.txt b/todo.txt index ce1aa9e..da619ce 100644 --- a/todo.txt +++ b/todo.txt @@ -11,7 +11,7 @@ xAdd enemy cars xAttacks president car xAdd dash xShoot from any direction -Shoot at continuous rate when holding shoot button +xShoot at continuous rate when holding shoot button Add local multiplayer Add netcode Add player damage