Jump to content

[Question] How to use the drawDebugSphere() function


tangowrangler

Recommended Posts

I tried to found some info and that is what I found:

 

You can look at dev's 'examples' in the following files:

data\scripts.old\entity\ai\mine.lua - line 141-147

data\scripts.old\entity\ai\salvage.lua - line 148-154

data\scripts.old\lib\entitydbg.lua - line 304-322

 

They're very similar though.

I suppose you should use this draw function inside of one of the following functions:

updateClient()

onPreRenderHud() - ClientSector Callbacks

onPostRenderHud() - ClientSector Callbacks

Link to comment
Share on other sites

Thanks for looking through it. I saw those examples but i messed that they need to be inside updateClient(). I tried the following but sadly that didnt work too....

 

 

function updateClient(timeStep)
    mycraft = Entity(Player().craftIndex)
    -- sp = Sphere(vec3(1000,0,0),4799)
   if valid(mycraft) then
        print("valid")
        drawDebugSphere(mycraft:getBoundingSphere(), ColorRGB(1, 0, 0))
    end
end

 

 

The only example of the Render callbacks i found were using the UIRenderer() object. Still i tried with the following without success

 

function update(timeStep)
    if onClient() then
        Player():registerCallback("onPreRenderHud", "onPreRenderHud")
    end
end

function onPreRenderHud()
    mycraft = Entity(Player().craftIndex)
   if valid(mycraft) then
        print("valid")
        drawDebugSphere(mycraft:getBoundingSphere(), ColorRGB(1, 0, 0))
    end
end

 

I am trying to slash around the need to use a debugsphere. It is being very inconvenient though. I need it cause i am trying to implement an object detection radar thingy for path planning in a sector. first i was using a sphere to get entities. than i kinda figured i can just iterate over all the entities in a sector. the get getEntitiesByLocation is faster than getting all entities; however, if u have relatively big spheres, the performances are comparable. I still  have to test it out in an asteroid field, that may explode the algorithm iterating over all entities.

 

Link to comment
Share on other sites

since its called drawDebugSphere, i suppose you wont see the sphere until some debug option is enabled (maybe its the "DebugScript" key binding? see game options for it).

I use other draw functions like drawText and they work fine in updateClient()and onPreRenderHud()!

Link to comment
Share on other sites

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
×
×
  • Create New...