I am trying to create a projectile that spawns a prop on the players location and then moves forward from that location. Eventually want to add physics and collision detection if possible but for now just trying to get the object to move.
using {/EpicGames.com/Simulation}
using {/Verse.org/Simulation}
using {/Fortnite.com/Game}
using {/EpicGames.com/Temporary/SpatialMath}
using {/Fortnite.com/Characters}
using { /Fortnite.com/Devices }
using { /EpicGames.com/Temporary/Diagnostics }
using {/Verse.org/Assets}
using {/Fortnite.com/Playspaces}
using {/Verse.org/Simulation/Tags}
using { /Fortnite.com/Devices/CreativeAnimation}
using {/Fortnite.com/Devices/Animation}
#Goal is to create a spawnable prop that acts as a projectile.
#[✓] need to get player location [✓]
#[✓] spawn prop at player location [✓]
#From the spawned location I want the projectile to move forward in the direction the player was facing when it was spawned.
#eventually would like to apply physics to this so projectiles can fall down or float away
#When the projectile collides with players I want it to cause damage
#when it hits terrain or props it stops with an adjustable time before it disappears
AweDamProjectile := class(creative_device){
@editable MyRemote : signal_remote_manager_device = signal_remote_manager_device{}
@editable animDevice : Prop2Fire = animation_controller
@editable Prop2Fire:creative_prop_asset := DefaultCreativePropAsset
@editable SpawnDistance: float = 2.45
@editable ProjSpeed: float = 0.5
@editable PropMoverProj: prop_mover_device = prop_mover_device{}
OnBegin<override>()<suspends>:void=
MyRemote.PrimaryActivationEvent.Subscribe(Function_1)
MyRemote.SecondaryFireEvent.Subscribe(Function_2)
Function_1(Player:player):void=
Print("Function 1 activated", ?Duration := 20.0)
Players:[]player := Self.GetPlayspace().GetPlayers()
for (Char -> Index : Players) {
if (FortChar := Players[Char].GetFortCharacter[]) {
tempprop:=SpawnProp(Prop2Fire,(((FortChar.GetTransform().Rotation.GetLocalForward()) * SpawnDistance) + FortChar.GetTransform().Translation),FortChar.GetTransform().Rotation)
tempprop.MoveTo((((tempprop.GetTransform().Rotation.GetLocalForward()) * SpawnDistance) + tempprop.GetTransform().Translation), tempprop.GetTransform().Rotation, ProjSpeed)
}
}
Function_2(Player:player):void=
Print("Function 2 activated", ?Duration := 20.0)
}