Jump to content

Collision bug, script error.


Recommended Posts

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 by Guest
Link to comment
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

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
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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...