I’m using the GetTransform().Translation to get the vector3 of the player position and adding the player view location to make the prop spawn in front of the player, where they’re looking.
I still want to keep the y and z position of the GetTransform().Translation, but want to use a Y position of 0, so the prop always spawns on the ground.
Any help is appreciated!
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
tower_placing := class(creative_device):
@editable Tower : creative_prop_asset = DefaultCreativePropAsset
@editable InputTriggerPlaceTower : input_trigger_device = input_trigger_device{}
OnBegin<override>()<suspends>:void=
InputTriggerPlaceTower.PressedEvent.Subscribe(SpawnMesh)
SpawnMesh( Agent : agent ) : void =
if (FortCharacter := Agent.GetFortCharacter[]):
PlayerPos := FortCharacter.GetTransform().Translation
PlayerForward := FortCharacter.GetViewRotation().GetLocalForward() * 300.0
PropSpawnPos := PlayerPos + PlayerForward
NewPropSpawn := vector3{X := PropSpawnPos, Y := 0.0, Z := PropSpawnPos}
#ERROR for PropSpawnPos in Vector3:
# This variable expects to be initialized with a value of type float,
# but this initializer is an incompatible value of type vector3
SpawnProp(Tower, NewPropSpawn, rotation{})
Print("Player Pos: {PlayerPos}")
Print("Prop Spawn Loc: {PropSpawnPos}")