Is there some function for finding objects similar to Game.FindPlayersInSphere?
I'm trying to bounce the ball on rocket imapct.
I would suggest instantiating a trigger area and then using the "GetOverlappingObjects()" method to find objects within the sphere. While this method is by no means graceful, it works for the most part.
--Core Asset Reference to a sphere trigger
local SphereAsset = script:GetCustomProperty("SphereAsset")
function GetObjectsInSphere(location, radius)
--You may need to divide my more or less than 100
--The "100" is just me guessing the radius for a trigger with a scale of (1, 1, 1)
local triggerScale = Vector3.ONE * radius/100
--Create an instance of the "SphereAsset" so that we can determine what objects are within the radius
local sphereInstance = World.SpawnAsset(SphereAsset, {position=location,scale=triggerScale})
--Get a list of objects within the trigger area
local objectsInSphere = sphereInstance:GetOverlappingObjects()
--Remove the sphere trigger
sphereInstance:Destroy()
--Return a list of objects that were within the sphere trigger
return objectsInSphere
end
Thank you both for reply. Spawning trigger would be the solution I was looking for.