Results 1 to 6 of 6
  1. #1
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    285

    Default A Problem with iterator (identify owner/not owner)

    Hi all,
    well my question is pretty simple I hope. I wrote an Iterator and it seem to work.
    But I use a third person camera and I'm checking for visible Pawns in range. It looks like my condition was written wrong because I don't want the owner pawn to be recognized but it does.

    Code:
    exec function CheckEnemy()
    {
    local Pawn checked;
    
            ForEach VisibleActors( class'Pawn', checked, 64,(Pawn != None) ? Pawn.Location : Location )
            {
              if (checked != none && checked != Owner)
              {
                `log("Enemy In Range");
              }
              else if (checked != none && checked == Owner)
              {
                `log("Something in Range");
              }
              else
              {
                `log("Nothin in Range");
              }
            }
    }
    When I start the Iterator in game, I just get:
    "Enemy in Range" although I can just see myself.
    I get
    "Enemy in Range"
    "Enemy in Range"
    when I see myself and the enemy pawn at once. What have I done wrong? Can someone help me with this?

  2. #2
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    64 units around the location of your Pawn is probably barely enough to get beyond your Pawn.

    Also, I believe that there is no Owner of a PlayerController - PlayerController typically owns a Pawn, not the other way around (unless you've followed one of the tutorials around here from ages ago that would botch that relationship up). My suggestion is to treat the PlayerController as if it's not an actual physical thing in the world, and use your Pawn for that sort of thing.

    However, if this code can run in a context where there is no Pawn, as it seems to indicate, then obviously you can throw some of that suggestion out.
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  3. #3
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    285

    Default

    I'm not sure if I totally understood what you told me.
    Do you want me to seek for Playercontrollers instead of Pawns?
    Your first sentence irritated me. I thought the radius value does check anything within the radius, not beyond.
    I think your last sentence does not apply on my case, because I'm pretty sure that it indicates my own pawn at least.

    But the most important thing is, what do I have to do now? Do I really have to check for Playercontrollers instead of pawns? Are Controllers handled as actors after all? Well I will try this evening thx for reply

  4. #4
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    484

    Default

    F4ll_ouT
    Maybe you need self or Pawn not Owner? (if your code in Pawn class - self, in controller - Pawn, it seems that this is controller class and you need Pawn).
    P.S.: In foreach works continue and break operators, it can simplify code sometimes.
    Last edited by rquester; 05-19-2012 at 10:27 AM.

  5. #5
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,274

    Default

    Code:
    exec function CheckEnemy()
    {
        local Pawn checked;
    
        foreach VisibleActors( class'Pawn', checked, 64, (Pawn != None) ? Pawn.Location : Location )
        {
            // unnecessary to test for None
            if( checked != Pawn )
            {
                `log("Enemy In Range");
            }
            else
            {
                `log("Nothin in Range");
            }
        }
    }

  6. #6
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    I'm sorry to have irritated you. o.O I mean, if you're looking for someone only within 64 units, at least in "normal" Unreal scale, that's only approximately 2/3rd the height of a UTPawn distance wise that you are searching.

    You want to search for Pawns, but you're checking to see if what you hit is the Owner. I assumed that your code is in your PlayerController, and the Owner of a PlayerController is usually None, I think.

    Overall, I think Spoof has written what you're looking for there, I was trying to explain why it wasn't working
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks


 

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.