fivem I’m working on a volleyball script how would i go about about detecting when an…
- User
fivem I’m working on a volleyball script how would i go about about detecting when an object hits the ground what is a better methord?
local groundThreshold = 0.5
Citizen.CreateThread(function() while true do Citizen.Wait(0)
codelocal volleyball = GetEntityCoords(volleyballObj) local isColliding = HasEntityCollidedWithAnything(volleyballObj) if isColliding and volleyball.z <= groundThreshold then – The volleyball has hit the ground TriggerEvent(‘your_event_name_here’) – replace your_event_name_here with the name of the event you want to trigger end endend)
or
local volleyball = CreateObject(GetHashKey(“prop_volleyball”), x, y, z, true) – Replace ‘prop_volleyball’ with your volleyball model name. SetEntityCollision(volleyball, true, true) SetEntityHasGravity(volleyball, true) ApplyForceToEntity(volleyball, 1, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0, true, true, false, true, true)
Citizen.CreateThread(function () while true do Citizen.Wait(50) – You can adjust this value for better performance, setting it too low might cause high CPU usage.
codelocal volleyballCoords = GetEntityCoords(volleyball) .local groundCoords = GetGroundZ(volleyballCoords) if groundCoords and volleyballCoords.z - groundCoords < 0.1 then print(“Volleyball hit the ground.”) – Add your logic or event triggers here. end endend)
Assistant
- User
How can I synchronize the ground hit detection across all clients and prevent cheaters from spoofing false impact events in multiplayer?
Assistant
- User
How do I handle ground impact detection when the volleyball lands on dynamic moving objects like platforms or vehicles instead of the static terrain?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.