Jump to content

(help) colshape & object


cacao

Recommended Posts

Hi everyone!

have here server-side script

local col = createColCircle(170, -377, 15)
local object = createObject(737, 175, -377, 6)
print(isElementWithinColShape(object, col)) -- print false

 

Can anyone tell me, why i got false, when object IN colshape?

Object and colshape have same coordinates.

Edited by cacao
Link to comment
local col = createColCircle(170, -377, 15)
local object = createObject(737, 175, -377, 6)
moveObject ( object, 100, 175, -378, 6 )
setTimer(function()
    print(isElementWithinColShape(object, col))
end, 500, 1, object)

I don't know if I did right, but try something like this, try using timers, since you have to move the element if they are at the same position when being created. So MTA can recognize when did the element hit the collision shape, so it can assign the isElementWithinColShape function to it, I guess. Try using something like I posted.

Link to comment
8 minutes ago, Dzsozi said:

local col = createColCircle(170, -377, 15)
local object = createObject(737, 175, -377, 6)
moveObject ( object, 100, 175, -378, 6 )
setTimer(function()
    print(isElementWithinColShape(object, col))
end, 500, 1, object)

I don't know if I did right, but try something like this, try using timers, since you have to move the element if they are at the same position when being created. So MTA can recognize when did the element hit the collision shape, so it can assign the isElementWithinColShape function to it, I guess. Try using something like I posted.

I tried it, but still false. :(

VrwbKdpUDpKOAX.jpg

Edited by cacao
Link to comment

You can move the colshape before you check the object though:

local col = createColCircle(2306.687, -1658.936, 14.386)
local object = createObject(737, 2306.687, -1658.936, 14.386)

addCommandHandler("c",
    function()
        local x,y,z = getElementPosition(col)
        setElementPosition(col,x,y,z+1)
        setElementPosition(col,x,y,z)
        print(isElementWithinColShape(object, col))
    end
)

I don't really know why it doesn't work normally, MTA is weird.

Edited by Tails
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...