Jump to content

[HELP] first marker overlaps second marker


kuwalda

Recommended Posts

Hello!

I have very tricky problem that I can`t manage to fix, maybe someone can help me out?

I will make this as basic as possible.

I have 2 markers:

* markerX with size of 10

* markerY with size of 50

Both markerX and markerY is attached to one object.

Lets say player is in both of them - he is inside markerX and markerY.

When checking isElementWithinMarker(player, markerX) and isElementWithinMarker(player, markerY) it returs that it is only inside markerY and does not recognize it is also inside of markerX.

My guess it is due marker overlapping, but am I right?

Any help or advices would be appriciated.

Link to comment

The problem is probably as you said due to overlapping the markers. However, there could be a method to do as you wish.

You could do some type of a code like this:

local m1 = createMarker ( 0, 0, 0, "cylinder", 5, 255, 255, 255, 120 ) 
local m2 = createMarker ( 0, 0, 0, "cylinder", 10, 255, 0, 0, 120 ) 
  
local data = { m1 = { }, m2 = { } } 
addEventHandler ( "onMarkerHit", root, function ( e ) 
    if ( source == m1 ) then 
        data.m1 [ e ] = true 
    elseif ( source == m2 ) then 
        data.m2 [ e ] = true 
    end 
end ) 
  
addEventHandler ( "onMarkerLeave", root, function ( e )  
    if ( source == m1 ) then 
        data.m1 [ e ] = nil 
    elseif ( source == m2 ) then  
        data.m2 [ e ] = nil 
    end 
end ) 
  
  
  
function isElementWithinMarkers ( p ) 
    return ( data.m1[p] and data.m2[p] ) == true 
end  

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