Dretax Posted August 20, 2017 Share Posted August 20, 2017 CreateCol's return is obviously a col object, and It's rotation can't be set. I'm trying to align the collosion with the attach, but there might be another options with it? Link to comment
Dretax Posted August 21, 2017 Author Share Posted August 21, 2017 Interesting. I wanted to create a code that could open a vehicle door in a fast and logical way, however createcol is not detecting the vehicle? (Client) function DoorOpener(button, press) if not press and button == "mouse2" then local px, py, pz = getElementPosition(getLocalPlayer()) local shape = createColCircle ( px, py, 6) outputChatBox("Length " .. #getElementsWithinColShape(shape, "vehicle")) -- Gives 0 back for _,v in ipairs(getElementsWithinColShape(shape, "vehicle")) do outputChatBox("Car found") local getComponent = getVehicleComponents(v) for k in pairs (getComponent) do local x, y, z = getVehicleComponentPosition(v, k, "world") local dist = getDistanceBetweenPoints3D (x, y, z, px, py, pz) outputChatBox("Dist: " .. dist) if dist < 1.5 then setVehicleDoorOpenRatio (v, k, 1 - getVehicleDoorOpenRatio(v, k), 0) end end end end end addEventHandler("onClientKey", getRootElement(), DoorOpener) Col is definetely within the vehicle, tested with showcol. Link to comment
Moderators IIYAMA Posted August 21, 2017 Moderators Share Posted August 21, 2017 The centre of the vehicle should be inside the col, otherwise it shouldn't be triggered. Also you have to take in consideration, that when you use colshapes it can fail to detect elements when they are already inside. This is a big problem serverside, yet for clientside it should be fine. If you can't get it to work use getElementsByType with streamedin argument ON + getDistanceBetweenPoints3D, to solve the issue. Link to comment
Zorgman Posted August 21, 2017 Share Posted August 21, 2017 Creating cols at say 0,0,-3 relative to your vehicle's position and moving them into position with moveElement won't help with the element hit problems? Link to comment
Dretax Posted August 27, 2017 Author Share Posted August 27, 2017 (edited) On 2017. 08. 22. at 01:18, Zorgman said: Creating cols at say 0,0,-3 relative to your vehicle's position and moving them into position with moveElement won't help with the element hit problems? On 2017. 08. 21. at 23:09, IIYAMA said: The centre of the vehicle should be inside the col, otherwise it shouldn't be triggered. Also you have to take in consideration, that when you use colshapes it can fail to detect elements when they are already inside. This is a big problem serverside, yet for clientside it should be fine. If you can't get it to work use getElementsByType with streamedin argument ON + getDistanceBetweenPoints3D, to solve the issue. None of them is the case. As I said, the col is within the vehicle. It just doesn't get detected. Lemme get a screenshot for you. 6m col, definetely within range. outputChatBox("Length " .. #getElementsWithinColShape(shape, "vehicle")) -- Gives 0 back Client side. But fine, I will do the streamin thing you suggested, but that might be using a little more. The moving won't help, since I directly have to check if the vehicle is there or not. Submitted a bug report. Edited August 27, 2017 by Dretax 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