Jump to content

Welcome to Omni-bot Forums
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

Vec3 inside an AABB, AABB.Contains(Vec3) returns 0

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Mateos

Mateos

    Senior Member

  • Members
  • 1,110 posts
  • LocationFrance

Good evening,

 

I'm writing for Gold Finger a little method to check if a bot is inside the elevator shaft but not inside the elevator itself, in which case the bot simply self-kills

 

It's working well for the elevator, but not the shaft...

 

Here're two screenshots of what's going on: https://imgur.com/a/1iQOB75

(First screen is a bit old, I had some vars in Map and not in the method back then)

 

I've drawn the 3 things to really visually check heh...

You can see the value is OK for the elevator, and the shaft check always returns 0, even though the red thingy is inside

 

 

The code, running through a thread:

    ManageElevatorStuckage = function()
    {
        sleepTime = 1;
 
        elevatorEntity = GetEntityByName( "t92" );
        elevatorShaft =  AABB( -65, -250, 1442, 38, -366, 8 );
 
        while ( 1 )
        {
            // Some drawing to see what's going on, and if it's going well...
            DrawEntityAABB( elevatorEntity, sleepTime, COLOR.YELLOW );
            DrawDebugAABB( elevatorShaft, COLOR.CYAN, sleepTime );
 
            // TODO: The GameEntity is kept up to date, extracting AABB perhaps not, so this is OK?
            elevatorEntityAABB = GetEntWorldAABB( elevatorEntity );
 
            //Util.MapDebugPrint( "elevatorEntityAABB = " + ToString( elevatorEntityAABB ), true );
 
            foreach ( id and bot in BotTable )
            {
                Util.MapDebugPrint( "Bot: " + bot.Name, true );
 
                // Get the bot eye position for intersection checks
                botEyePosition = GetEntEyePosition( bot.GetGameEntity() );
                if ( !botEyePosition )
                {
                    Util.MapDebugPrint( bot.Name + "^b hasn't eyes...", true );
                    continue;
                }
 
                // Temp test to see a line from the bot's head...
                testVec3 = Vec3( botEyePosition.x + 10, botEyePosition.y + 10, botEyePosition.z + 10 );
                DrawDebugLine( botEyePosition, testVec3, COLOR.RED, sleepTime );
 
                //Util.MapDebugPrint( "botEyePosition = " + ToString( botEyePosition ), true );
 
                Util.MapDebugPrint( "elevatorShaft.Contains( botEyePosition ) = " + ToString( elevatorShaft.Contains( botEyePosition ) ), true );
                Util.MapDebugPrint( "!elevatorEntityAABB.Contains( botEyePosition ) = " + ToString( !elevatorEntityAABB.Contains( botEyePosition ) ), true );
 
                // If this position is inside the shaft but not inside the elevator,
                // Simply kill the bot... Enough of this
                if ( elevatorShaft.Contains( botEyePosition ) && !elevatorEntityAABB.Contains( botEyePosition ) )
                {
                    bot.ExecCommand( "kill" );
                    Util.MapDebugPrint( bot.Name + "^b was in the elevator shaft but not the elevator itself...", true );
                }
            }
 
            // This is an infinite loop...
            //yield();
            sleep( sleepTime );
        }
    },

Really written "shaft contains bot's eyes"...

 

Attached the whole script if you're willing to look at it whole

 

I can't see what's wrong? :'(

 

Edit: Could it be something about the way I defined that AABB? :/

 

Thank you ^^'

Attached Files


Edited by Mateos, 24 March 2020 - 06:42 PM.

mateos1.png


#2
palota

palota

    Senior Member

  • Administrators
  • 574 posts

Upper bounds of AABB must be greater than lower bounds. That's why AABB( -65, -250, 1442, 38, -366, 8 ) is invalid and AABB( -65, -366, 8, 38, -250, 1442 ) is correct.

But I don't like killing bots. It would be better to modify the paththrough navigation. You could check the position after pressing the elevator button. If the bot is still at the bottom of the shaft then he should go out and try again.

 


  • Mateos likes this

#3
Mateos

Mateos

    Senior Member

  • Members
  • 1,110 posts
  • LocationFrance

Thank you, I expected something like this yeah

 

The handling at the bottom works; the problem is when a bot is stuck above the elevator

 

Well I can simply check if the position is inside the shaft and above the elevator for the suicide condition then

And inject in the path through the position check as well, so a bot thinking he's in while actually being below will exit the loop and then exit the shaft

 

Edit: What are the properties of the AABB object? Wiki supplied operations but not these; just to reach the top Z value


Edited by Mateos, 28 March 2020 - 10:42 AM.

mateos1.png





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users