using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters}
using { /UnrealEngine.com/Temporary/SpatialMath}
See Create Your Own Device Using Verse for how to create a verse device.
A Verse-authored creative device that can be placed in a level
Football_movement := class(creative_device):
@editable
ball : creative_prop = creative_prop{}
Magnitude(vector:vector3):float=
return Sqrt(Pow(vector.X, 2.0) + Pow(vector.Y, 2.0) + Pow(vector.Z, 2.0))
Normalize(vector:vector3):vector3=
Mag := Magnitude(vector)
return vector3{X := vector.X/Mag, Y := vector.Y/Mag, Z:= vector.Z/Mag}
dribble()<suspends> : void =
loop:
ballTransform := ball.GetTransform().Translation
MoveTime := 0.001
if(PlayerList := GetPlayspace().GetPlayers(), FortniteCharacter := PlayerList[0].GetFortCharacter[]):
PlayerPosition : vector3 = FortniteCharacter.GetTransform().Translation
PlayerRotation := FortniteCharacter.GetTransform().Rotation
PlayerYawPitchRoll := PlayerRotation.GetYawPitchRollDegrees()
if(NewYaw := PlayerYawPitchRoll[0] - 90.0):
if(CorrectedPlayerRotation := MakeRotationFromYawPitchRollDegrees(NewYaw, PlayerYawPitchRoll[1], PlayerYawPitchRoll[2])):
PlayerLocalForward := CorrectedPlayerRotation.GetLocalForward()
Normalized_Forward_Vector := Normalize(PlayerLocalForward)
Dist := 10.0
Target_Location : vector3 = vector3:
X := Normalized_Forward_Vector.X * Dist
Y := Normalized_Forward_Vector.Y * Dist
Z := Normalized_Forward_Vector.Z * Dist
ball.MoveTo(Target_Location, PlayerRotation, MoveTime)
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
dribble()
also, I have removed the prop_loc + from the X, Y and Z variables because the ball drifts slowly in one direction and doesn’t follow anything. Now all it does is sink into the ground and rotate towards the player, but not move towards the player.