Log in to reply
 

Get dimensions of Entity like Cars



  • Hi,
    I am using ScriptHook V to program some custom functions for GTAV. Given that I have an entity available using the variable entityHandle, is there a way to get the length, width and height of the entity?

    For example, if I am looking for the center of the Entity i can just do:

    Vector3 objCenter = ENTITY::GET_ENTITY_COORDS(entityHandle, TRUE);
    

    Is there something similar for getting the dimensions of the entity?
    Any help is greatly appreciated!



  • Vector3 modelDimMin, modelDimMax;
    GAMEPLAY::GET_MODEL_DIMENSIONS(ENTITY::GET_ENTITY_MODEL(vehicle), &modelDimMin, &modelDimMax);
    

    Bounding box:

        Vector3 lfd = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMin.x, modelDimMax.y, modelDimMin.z);
        Vector3 lfu = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMin.x, modelDimMax.y, modelDimMax.z);
        Vector3 rfd = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMax.x, modelDimMax.y, modelDimMin.z);
        Vector3 rfu = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMax.x, modelDimMax.y, modelDimMax.z);
        Vector3 lrd = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMin.x, -modelDimMax.y, modelDimMin.z);
        Vector3 lru = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMin.x, -modelDimMax.y, modelDimMax.z);
        Vector3 rrd = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMax.x, -modelDimMax.y, modelDimMin.z);
        Vector3 rru = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, modelDimMax.x, -modelDimMax.y, modelDimMax.z);
    
        GRAPHICS::DRAW_LINE(lfd.x, lfd.y, lfd.z, rfd.x, rfd.y, rfd.z, 255, 255, 255, 255); // Front low
        GRAPHICS::DRAW_LINE(lfu.x, lfu.y, lfu.z, rfu.x, rfu.y, rfu.z, 255, 255, 255, 255); // Front high
        GRAPHICS::DRAW_LINE(lfd.x, lfd.y, lfd.z, lfu.x, lfu.y, lfu.z, 255, 255, 255, 255); // Front left
        GRAPHICS::DRAW_LINE(rfd.x, rfd.y, rfd.z, rfu.x, rfu.y, rfu.z, 255, 255, 255, 255); // Front right
    
        GRAPHICS::DRAW_LINE(lrd.x, lrd.y, lrd.z, rrd.x, rrd.y, rrd.z, 255, 255, 255, 255); // Rear low
        GRAPHICS::DRAW_LINE(lru.x, lru.y, lru.z, rru.x, rru.y, rru.z, 255, 255, 255, 255); // Rear high
        GRAPHICS::DRAW_LINE(lrd.x, lrd.y, lrd.z, lru.x, lru.y, lru.z, 255, 255, 255, 255); // Rear left
        GRAPHICS::DRAW_LINE(rrd.x, rrd.y, rrd.z, rru.x, rru.y, rru.z, 255, 255, 255, 255); // Rear right
    
        GRAPHICS::DRAW_LINE(lfu.x, lfu.y, lfu.z, lru.x, lru.y, lru.z, 255, 255, 255, 255); // Left up
        GRAPHICS::DRAW_LINE(rfu.x, rfu.y, rfu.z, rru.x, rru.y, rru.z, 255, 255, 255, 255); // Right up
        GRAPHICS::DRAW_LINE(lfd.x, lfd.y, lfd.z, lrd.x, lrd.y, lrd.z, 255, 255, 255, 255); // Left down
        GRAPHICS::DRAW_LINE(rfd.x, rfd.y, rfd.z, rrd.x, rrd.y, rrd.z, 255, 255, 255, 255); // Right down
    


  • @ikt Wow thanks a lot really appreciate it!!


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.