thaman667 Posted May 5, 2013 Share Posted May 5, 2013 (edited) When I load the object normally in the object has collision. But when I attach it to my car with a marker it has no collision whatsoever so I know it's a scripting error of mine. I have the following 2 script files: client.lua: setCloudsEnabled ( false ) function objects () local capt_rail_col = engineLoadCOL("capt_rail.col") engineReplaceCOL(capt_rail_col, 1339) local capt_rail = engineLoadDFF('capt_rail.dff', 0) engineReplaceModel(capt_rail, 1339) local hook_col = engineLoadCOL("hook.col") engineReplaceCOL(hook_col, 1337) local hook = engineLoadDFF('hook.dff', 0) engineReplaceModel(hook, 1337) end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), objects ) marker.lua: local marker = createMarker(2449,-1657,12.948616027832,"corona",4,230,230,230,230) local objectAttached = nil function markerHit (hitPlayer, match) if (source == marker) and match and hitPlayer == localPlayer then if not objectAttached then local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle then local object = createObject(1337, 0,0,0) setElementDoubleSided ( object, true ) attachElements(object, vehicle, 0, 0, 0.7, 0, 0, 0) objectAttached = true end end end end addEventHandler("onClientMarkerHit", root, markerHit) Thanks in advance! Edited May 6, 2013 by Guest Link to comment
xXMADEXx Posted May 6, 2013 Share Posted May 6, 2013 First of all, use "[lua]" tag, not pastebin.... Ingame, use the command /debugscript 3 (If you havn't already.) I think it will have to do something with the .col files, and not the script. Link to comment
thaman667 Posted May 6, 2013 Author Share Posted May 6, 2013 First of all, use "[lua]" tag, not pastebin....Ingame, use the command /debugscript 3 (If you havn't already.) I think it will have to do something with the .col files, and not the script. I wouldn't be here if I didn't try the debugscript 3. And the col files are not buggy as I said in the previous post. Link to comment
thaman667 Posted May 6, 2013 Author Share Posted May 6, 2013 Its an MTA related "glitch". MTA automatically disallow the collision on the attached object. I want this to be ignored, so it keeps colliding with other objects. Link to comment
DiSaMe Posted May 6, 2013 Share Posted May 6, 2013 Is collision really disabled? When you walk into the object, do you go through it? If so, then yes, the collision is disabled. But if the object only goes through other objects, that's not a 'bug'. It's just the way the attachments work. First, the attached element is fixed to the attachment offset. And second, the physics of attached element do not affect the element it's attached to. As a result, it acts line an object of infinite mass. When it intersects other objects of infinite mass, they go through each other. But if it collides an element of a finite mass (such as a vehicle), that element gets pushed with no effort. Link to comment
thaman667 Posted May 6, 2013 Author Share Posted May 6, 2013 Is collision really disabled? When you walk into the object, do you go through it? If so, then yes, the collision is disabled. But if the object only goes through other objects, that's not a 'bug'. It's just the way the attachments work. First, the attached element is fixed to the attachment offset. And second, the physics of attached element do not affect the element it's attached to. As a result, it acts line an object of infinite mass. When it intersects other objects of infinite mass, they go through each other. But if it collides an element of a finite mass (such as a vehicle), that element gets pushed with no effort. Thanks for the explanation but this doesn't help me. I want the attached object to collide with other objects/world and not with other cars. Is this possible? Link to comment
DiSaMe Posted May 6, 2013 Share Posted May 6, 2013 Since static objects don't collide with each other, that requires a script which detects the collisions and applies the force itself. You can do this using these functions: isLineOfSightClear processLineOfSight setElementVelocity setVehicleTurnVelocity But that requires some experience related to calculations in 3D. Link to comment
thaman667 Posted May 6, 2013 Author Share Posted May 6, 2013 Since static objects don't collide with each other, that requires a script which detects the collisions and applies the force itself. You can do this using these functions: isLineOfSightClear processLineOfSight setElementVelocity setVehicleTurnVelocity But that requires some experience related to calculations in 3D. Well fuck.. Link to comment
itoko Posted May 6, 2013 Share Posted May 6, 2013 hmm maybe you could manage to set the object position instead of attaching it 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