Lergen Posted April 10, 2021 Share Posted April 10, 2021 Is it possible to have serverside peds trigger a colshape? I would assume that this should be possible, but I simply cannot seem to get them to trigger it. Empty vehicles, the player and etc elements seem to work, just not the peds. testPed = createPed ( id, x, y, z, r ) setPedAnimation(testPed, "ped", "WOMAN_run") testZone = createColRectangle ( x, y, fwidth, fheight ) function testFunc ( targetElem ) setElementAlpha ( targetElem, 0 ) end addEventHandler ( "onColShapeHit", testZone, testFunc ) In this example I create a ped, and have it run toward the direction of the colshape. However it does not trigger the function attached to the colshape. I used changing the alpha for this example but chatbox outputs, etc all similarly fail to trigger from serverside peds. Anything else that enters it will trigger it as it should, just not the peds for whatever reason. Am I forgetting something here? Any advice would be appreciated. Link to comment
Lergen Posted April 10, 2021 Author Share Posted April 10, 2021 After further testing, it seems any objects created serverside with createObject, then moved with the moveObject function into it don't trigger the colshape hit event either. Vehicles and players seem to be the only thing that actually trigger the event. I'd assume objects and peds created on the server should also be "seen" by a serverside colshape. Not sure what I'm missing here. Link to comment
Discord Moderators Zango Posted April 14, 2021 Discord Moderators Share Posted April 14, 2021 I tested your first example, and it works fine, the ped is detected when he runs into the colshape. testPed = createPed(0, 0, 0, 3) setTimer(setPedAnimation, 100, 1, testPed, "ped", "WOMAN_run") testZone = createColRectangle(-10, 10, 50, 50) function testFunc(targetElem) setElementAlpha(targetElem, 0) end addEventHandler("onColShapeHit", testZone, testFunc) For moveObject however, you're right that it doesn't work. When you move an object serverside, it tells all clients to move the object, but nothing happens on the server. If you use getElementPosition while it's moving, it'll calculate the interpolated position (where it's supposed to be) and give you that. But it doesn't actually do anything while the object is moving, and thats why it doesn't run the colshape collision detection. If you use setElementPosition however, it'll run the spatial checks, and trigger the colshape. I suggest you move the colshape detection to a clientside script, where the object is a physical entity which gets updated every frame. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now