World::Oject ID problem

  • When I call GetID() on a world object associated with a vehicle, it looks like the function returns the Type ID, not the Full ID (unique ID) for that world object. Example:

    void MyFunction(Sensor *s) {
      s->SetParentByLocality();    // attach the sensor to a vehicle
      World::Object *parentWorldObj = s->GetWorldObject()->GetParent();    // get the sensor's parent world object
      LogMessage("Parent ID: " + StringConverter::ToString(parentWorldObj->GetId());    // this prints a value that matches the 'Type ID' property of the vehicle's world object, rather than the 'Full ID'

    What am I missing?

  • Good morning,
    In this circumstance, you should call the GetComplexID() method on pParent instead of GetId(). That will return the specialized ID type, which in this case should be either a Vehicle, or a Vehicle Object.

    Here's a code sample, similar to what is used to get the owning ID, to grab the specific ID of the parent vehicle:

    ID parentID = pParent->GetComplexID();
    Vehicles::Vehicle* pVehicle = nullptr;
    //if we are a vehicle object, or a vehicle itself, attach to the vehicle
    if ( GetDataType( parentID ) == Types::VehicleObject )
        Vehicles::Object* pVehObj = static_cast<Vehicles::Object*>( pParent );
        pVehicle = pVehObj->GetOwner();
    else if ( GetDataType( parentID ) == Types::Vehicle )
        pVehicle = Vehicles::Manager::GetSingleton().GetVehicle( parentID );

    Please let us know how that works for you.

    The ANVEL Team

Log in to reply

Looks like your connection to ANVEL Forum was lost, please wait while we try to reconnect.