Jump to content

ColShape detection


Recommended Posts

Hello, I'm trying to make a script, but I have a problem, the world object does not get detected when the colShape touches it. I'd like the onClientColShapeHit event to be triggered when a world object touches the colShape, or at least to get a function that can trigger an event if a world object is in a certain distance from the back of the player, how can I do it?

local x,y,z = getElementPosition(localPlayer) 
local cols = createColSphere (x+2,y,z,0.5) 
setDevelopmentMode (true) 
    local screenWidth, screenHeight = guiGetScreenSize() 
    if isElement(cols) then 
        local playerrot = getPedRotation ( getLocalPlayer () ) 
        local radRot = math.rad ( playerrot ) 
        local radius = 1 
        local px,py,pz = getElementPosition( getLocalPlayer () ) 
        local tx = px + radius * math.sin(radRot) 
        local ty = py + -(radius) * math.cos(radRot) 
        local tz = pz 
        setElementPosition ( cols, tx, ty, tz ) 
addEventHandler ("onClientColShapeHit",getRootElement(),function(theElement) 
if getElementType (theElement)=="object" then 
outputChatBox ("it works") 

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