Created
October 30, 2023 19:02
-
-
Save LionGet/48837e2fe65635534c86df81c7a391fc to your computer and use it in GitHub Desktop.
+1 on Zmak Move Prop In Arc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using { /Fortnite.com/Devices } | |
using { /Verse.org/Simulation } | |
using { /UnrealEngine.com/Temporary/Diagnostics } | |
using { /Fortnite.com/Devices/CreativeAnimation } | |
using { /UnrealEngine.com/Temporary/SpatialMath } | |
ArcAdvanced := class<concrete>: | |
@editable TimeBetweenPoints : float = 0.1 | |
@editable AmountOfPoints : int = 500 | |
MoveInPropInArc := class(creative_device): | |
@editable var UnitDirection : vector3 = vector3{X:=1.0,Z:=1.0} | |
@editable var Power : float = 200.0 | |
@editable var Gravity : float = 9.8 | |
@editable PropLaunch : creative_prop_asset = DefaultCreativePropAsset | |
@editable ActionButton : button_device = button_device{} | |
@editable MenuButton : button_device = button_device{} | |
@editable MenuOptions : popup_dialog_device = popup_dialog_device{} | |
@editable Advanced : ArcAdvanced = ArcAdvanced{} | |
var LaunchedProp : creative_prop = creative_prop{} | |
var MoverLocation:transform=transform{} | |
var IsLaunched:logic=false | |
OnBegin<override>()<suspends>:void= | |
ActionButton.InteractedWithEvent.Subscribe(OnButtonInteracted) | |
MenuOptions.RespondingButtonEvent.Subscribe(ChangeValues) | |
ChangeValues(Agent:agent,Response:int):void= | |
if(Response=1): | |
set Power += 25.0 | |
if(Response=2): | |
set Power -= 25.0 | |
if(Response=3): | |
set UnitDirection.X+=0.05 | |
set UnitDirection.Z+=0.1 | |
if(Response=4): | |
set UnitDirection.X-=0.05 | |
set UnitDirection.Z-=0.1 | |
if(Response=5): | |
set Gravity += 0.1 | |
if(Response=6): | |
set Gravity -= 0.1 | |
Print("Power:{Power},Direction X:{UnitDirection.X} Z:{UnitDirection.Z},Gravity{Gravity}") | |
OnButtonInteracted<public>(Agent : agent) : void = | |
if(IsLaunched=true): | |
if(LaunchedProp.IsValid[]): | |
LaunchedProp.Dispose() | |
set IsLaunched=false | |
if(IsLaunched=false): | |
if(Prop:=SpawnProp(PropLaunch, MenuButton.GetTransform())(0)?): | |
set LaunchedProp = Prop | |
LaunchedProp.PlayArc(UnitDirection) | |
set IsLaunched=true | |
#Function that uses the animation controller to predict the arc of the prop | |
(Prop : creative_prop).PlayArc(UnitDir : vector3):void= | |
var LastLocation : vector3 = Prop.GetTransform().Translation | |
if (AnimationController := Prop.GetAnimationController[]): | |
L_KeyFrames : []keyframe_delta = for (I := 0..Advanced.AmountOfPoints): | |
var Loc : vector3 = (((Power * UnitDir)* Advanced.TimeBetweenPoints) -vector3{Z:=(Gravity * Advanced.TimeBetweenPoints)*I}) | |
if (LastLocation.Z < 0.0):#If the prop is below the map, stop the animation | |
set Loc = vector3{X:=0.0,Y:=0.0,Z:=0.0} | |
set LastLocation = Loc + LastLocation | |
KeyFrame := keyframe_delta : | |
DeltaLocation := Loc | |
DeltaRotation := IdentityRotation() | |
Time := Advanced.TimeBetweenPoints | |
AnimationController.SetAnimation(L_KeyFrames, ?Mode:=animation_mode.OneShot) | |
AnimationController.Play() | |
Print("Animation Playing") | |
Print("Animation Failed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment