Community Forum
ANVEL Licensing Options

Derived Trigger Volume Component



  • I'm trying to create a component plugin that inherits some of the functionality of the Trigger Volume Component. I seem to encounter an error if I try to call for the base functions.

    Error LNK2001 unresolved external symbol "public: void __cdecl Anvel::TriggerVolumeComponent::OnSimUpdate(double)" (?OnSimUpdate@TriggerVolumeComponent@Anvel@@QEAAXN@Z)

    Here is an example of what I'd try to do:

    void SampleObjectTrigger::SampleFunction(TimeValue dt)
    {
    /// do some stuff
    TriggerVolumeComponent::OnSimUpdate(dt);
    /// do some more stuff
    }

    I'll also get the error if during the RegisterProperties function when I'll try this

    void SampleObjectTrigger::RegisterProperties(PropertyRegistrationContext& context)
    {
    TriggerVolumeComponent::RegisterProperties(context);
    ///add other properties
    }

    Any ideas?



  • .Bump.



  • Hi @jayatc,

    We'll be happy to take a look into this issue. First off, it would be helpful to know what you're missing from the trigger volume component that would require you to extend the base functionality. If we understand your goals, we can recommend the best approach!

    Regards,
    ANVEL Support



  • @anvel-team I'm doing simulated convoy operations and I want the event to be triggered when a certain vehicle passes through the trigger volume not necessarily when the first vehicle passes through. I know that I could place the volume further down the path in order to line up with the timing, but I want to alter speeds and gap distances in the convoy and I'm finding it cumbersome to continuously move the volume.

    I'm also hoping to allow multiple events to be triggered by multiple instances of vehicles passing through the volume. i.e. vehicle A passes through do event A, when vehicle B passes through do event B.



  • @jayatc,

    We're working on some examples that incorportate trigger volumes and Python scripting components that should give you an example of what you can do with these functionalities! Thanks for your patience!

    Regards,
    ANVEL Support



  • @JayATC,

    We have the beginnings of an example for you that might help triggering your events when a certain vehicle passes through the volume.

    The idea is that the Python script below can be attached to an object with a TriggerVolume component. Save it as TriggerVolumeExample.py (or similarly named) in the objects folder, and it will show an ID entry in the custom properties field. Check it out:

    ===========================================
    import Anvel
    import Anvel.Scripting
    
    #This script will utilize the Anvel Message system to receive updates when an object has entered in to this
    #trigger volume. The message 
    def OnObjectEntered(state, params):
        id = params[0]
        #Verify that the entered messa
        if state.triggerVolumeId == params[1]:
            Anvel.Log("Object entered: " + str(id) )
            if state.TargetId == id:
                Anvel.Log("Target id entered!")
    
    def Initialize(state):
        #First verify that we have an attached Trigger Volume component. If not, log an error and 
        #bail
        triggerVolumeIds = Anvel.GetComponentIdsOfType(state.id, Anvel.Enums.ComponentType.TriggerVolume)
        if len(triggerVolumeIds) == 0:
            Anvel.Error("No TriggerVolume attached to this object. Script will not be processed.")
            return
        #Save our trigger volume component id, which can be used to filter the ObjectEnteredTrigger
        #messages to only the component we are attached to.
        state.triggerVolumeId = triggerVolumeIds[0]
        #Subscribe to the message published by TriggerVolumes when an object enters
        Anvel.Scripting.SubscribeToMessage(state, Anvel.Messages.ObjectEnteredTrigger, OnObjectEntered)
        #Allow the user to optionally set a specific ID to check for
        Anvel.Scripting.AddProperty(state, "TargetId", Anvel.Enums.VariantTypes.Id)
    

    Regards,
    ANVEL Support