Results 1 to 19 of 19
  1. #1
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Question Trigger Question

    I am fairly new to unreal script, so I apologize in advance for the basic question. I am am trying to determine what trigger was touched in order to update the HUD with the appropriate information. I can get the names of the triggers that exist but I don't know how to determine which one was touched. Please help!

    Thanks in advance.

  2. #2
    MSgt. Shooter Person
    Join Date
    Nov 2011
    Posts
    60

    Default

    In your kismet, you right click, then select, "Select trigger on level" to know which trigger is being used. hope this helps.

  3. #3
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    Do I need to add it to Kismet in order to determine in unreal script if the triggers has been touched?

  4. #4
    Boomshot

    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    2,162

    Default

    When a trigger gets touched a function called Touched (or something similar) gets called. You can use that so when the trigger gets touched (you can also check by what it got touched I think) you update the toucher's HUD.

  5. #5
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    This is what I currently have

    event PostRender()
    {
    //Attempting to determine if Trigger_0 (in the editor) was touched
    local Trigger T;
    local string DrawMyText;
    //local Pawn MyPawn;

    foreach DynamicActors(class'Trigger', T, )
    {
    if(T.Name == 'Trigger_0')
    {
    //T.Touch();
    //This is the T (Trigger) I want..
    if(Touch(T))
    {
    DrawMyText = "This is the correct trigger, Trigger_0";
    }
    }
    else if (T.Name == 'Trigger_1')
    {
    //This is Trigger 1..
    DrawMyText = "This is Trigger_1";
    }
    }

    Canvas.SetPos(50,50);
    Canvas.SetDrawColor(255,255,255,200);
    Canvas.Font = class'Engine'.static.GetSmallFont();
    Canvas.DrawText(DrawMyText);
    }

    i get the following error when compiling...

    Call to 'Touch': missing or bad parameter 2

  6. #6
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    u shouldnt do this in script. in kismet u should make a trigger. then open kismet and click event with trigger_X and wen the specific trigger is touched u should either render HUD or Open a gFX. Read more about the kismet HUD functions in Kismet reference in udn to know which function suits u I hope it helps!

  7. #7
    Boomshot

    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    2,162

    Default

    Use this trigger class:
    Code:
    class NewTrigger extends Trigger;
    
    // The boolean variable.
    bool WasTouched;
    
    // The touch event (called when something touchs the trigger).
    event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
    {
        if (FindEventsOfClass(class'SeqEvent_Touch'))
        {
            NotifyTriggered();
        }
        // It was touched.
        WasTouched = true;
    }
    
    // Default values.
    DefaultProperties
    {
        // Initially FALSE.
        WasTouched=false;
    }
    and this:
    Code:
    event PostRender()
    {
        //Attempting to determine if Trigger_0 (in the editor) was touched
        local Trigger T;
        local string DrawMyText;
        //local Pawn MyPawn;
    
        /* Not sure if you need to replace 'Trigger' with 
         * the name of the new trigger. @100GPing100 */
        foreach DynamicActors(class'Trigger', T, )
        {
            if(T.Name == 'Trigger_0')
            {
                //T.Touch();
                //This is the T (Trigger) I want..
                if (T.WasTouched) // Will be true if it has ever been touched. @100GPing100
                {
                    DrawMyText = "This is the correct trigger, Trigger_0";
                }
            }
            else if (T.Name == 'Trigger_1')
            {
                //This is Trigger 1..
                DrawMyText = "This is Trigger_1";
            }
        }
    
        Canvas.SetPos(50,50);
        Canvas.SetDrawColor(255,255,255,200);
        Canvas.Font = class'Engine'.static.GetSmallFont();
        Canvas.DrawText(DrawMyText);
    }

    Also, next time use code tags, like this:
    [code_]MY CODE[ /code_]
    without the underscores ('_').

  8. #8
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    Thanks for the help, I will try it shortly.

    I will be sure to use the code wrapper next time.

  9. #9
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    I get the following error when compiling...

    Unrecognized member 'WasTouched' in class 'Trigger'

    What am I doing wrong?

  10. #10
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    Event Touch is the right one

  11. #11
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    I changed it to EventTouch and I still get the same error.

  12. #12
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    show me ur code

  13. #13
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    like i said code is not the right way kismet is. make an event with the trigger u want to use and connect the touched with a HUD node.

  14. #14
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    here is the code i have currently...

    this is the Trigger class

    Code:
    class NewTrigger extends Trigger;
    
    // The boolean variable.
    var bool WasTouched;
    
    // The touch event (called when something touchs the trigger).
    event EventTouch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
    {
        if (FindEventsOfClass(class'SeqEvent_Touch'))
        {
            NotifyTriggered();
        }
        // It was touched.
        WasTouched = true;
    }
    
    // Default values.
    DefaultProperties
    {
        // Initially FALSE.
        WasTouched=false;
    }
    here is the Post Render in my custom HUD
    Code:
    event PostRender()
    {
        //Attempting to determine if Trigger_0 (in the editor) was touched
        local Trigger T;
        local string DrawMyText;
    
        foreach DynamicActors(class'Trigger', T, )
        {
            if(T.Name == 'Trigger_0')
            {
                //This is the T (Trigger) I want..
                if (T.WasTouched) // Will be true if it has ever been touched.
                {
                    DrawMyText = "This is the correct trigger, Trigger_0";
                }
            }
            else if (T.Name == 'Trigger_1')
            {
                //This is Trigger 1..
                DrawMyText = "This is Trigger_1";
            }
        }
    
        Canvas.SetPos(50,50);
        Canvas.SetDrawColor(255,255,255,200);
        Canvas.Font = class'Engine'.static.GetSmallFont();
        Canvas.DrawText(DrawMyText);
    }

  15. #15
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    480
    Gamer IDs

    PSN ID: eshwarlion

    Default

    EventTouch is not an event just Touch is

  16. #16
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    i tried Touch first, no luck.

  17. #17
    Boomshot

    Join Date
    Feb 2010
    Location
    Portugal
    Posts
    2,162

    Default

    The comment had the fix
    Code:
    event PostRender()
    {
        //Attempting to determine if Trigger_0 (in the editor) was touched
        local Trigger T;
        local string DrawMyText;
        //local Pawn MyPawn;
    
        /* Not sure if you need to replace 'Trigger' with 
         * the name of the new trigger. @100GPing100 */
        foreach DynamicActors(class'NewTrigger', T, )
        {
            if(T.Name == 'Trigger_0')
            {
                //T.Touch();
                //This is the T (Trigger) I want..
                if (T.WasTouched) // Will be true if it has ever been touched. @100GPing100
                {
                    DrawMyText = "This is the correct trigger, Trigger_0";
                }
            }
            else if (T.Name == 'Trigger_1')
            {
                //This is Trigger 1..
                DrawMyText = "This is Trigger_1";
            }
        }
    
        Canvas.SetPos(50,50);
        Canvas.SetDrawColor(255,255,255,200);
        Canvas.Font = class'Engine'.static.GetSmallFont();
        Canvas.DrawText(DrawMyText);
    }
    You had to use the new Trigger's name (marked in red) so it would know it was the new type.

    Remmember that this uses NewTrigger, the class I gave you in my last post.
    Last edited by 100GPing100; 02-12-2012 at 01:18 PM. Reason: added new line characters

  18. #18
    Skaarj
    Join Date
    Jul 2011
    Location
    Louisiana, USA
    Posts
    10

    Default

    thanks so much, i completely overlooked the comment .

  19. #19


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.