Announcement

Collapse
No announcement yet.

Can't think please help.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can't think please help.

    simulated function VisableRange()
    {
    local Pawn P;

    foreach AllActors(class'Pawn', P)
    {
    if (VSize(self.Location - P.Location) > HiddenDistance)
    {
    bHidden=True;
    }
    else
    {
    bHidden=False;
    }
    }
    }

    tick is checking this. why isn't it setting bHidden back to false when the IF statement isn't true... (i'm new to ELSE)

    also, since this is simulated this means it'll be for each player now right? some ppl see it some dont.

    #2
    First off I highly reccomend against doing a foreach every tick, Foreach iterators are highly inefficient. If you are though use VisibleCollidingActors, it's way more efficient.

    Second I can see thi essentially rendering anything invisbile visble in a flickering sort of way if more then one team is lookin at it (that's asssuming the variable bvisible variable is replicated)

    Something I'd reccomend looking at is how ONS put's health bars on nodes and vehciles, it's part of the HUD, and the RadarMap, I'm sure you'd be able to put a icon only viible to the player who's team is the same this way...

    As for your item up there try...
    Increasine loweing the hide distnace
    Try commenting out the secong bHidden= False statement, see if it actually makes the object invisble to begin with...

    Last try using 'else if'

    Comment


      #3
      Even with your assistance I'm stuck. thanks tho.

      Anyone care to take a moment to explain how I can make a vehicle hidden to a player if they are far enough away but may not be hidden to another player if they are close enough?

      doin research I'm thinking this envolves replication which I haven't gotten into too much yet. I could be wrong. Other than "read a guide on wiki!!!111oneone" would someone please take time to help me :P

      Comment


        #4
        As for your original post have you debugged it and know for sure that the ELSE block is ever reached? Put some sort of output to the log to see if it ever occurs, if it doesnt then the if statement is always occuring and bHidden is always true.

        There is really no reason that an if-then-else statement wont do something what you ask (especially when its as simple as setting one single boolean var) unless the conditions are not set quite right and it always goes into the same block (if block for always true and else block for always false).

        Which is what Hsoolien meant by lowering or raising the hidden distance. Though I wouldn't really bother using "else if" since you add more conditions and even more possibilities of errors, usually.

        I start by debugging and printing out the values that your working with in the conditions. So basically print out self.Location then print out P.Location then print out the maths (the minus operation) just for convenience, then print out the hiden distance... you should then see patterns occuring such as the value of your equation is ALWAYS higher than the hidden distance.

        Comment


          #5
          The problem is the iterator, not the If. What it boils down to is whether or not the last pawn you check is further away than HiddenRange.

          Instead of having the pawn hide itself from other players, why not have the players hide the pawn from themselves?

          Comment


            #6
            Would you provide an example, please?

            Comment


              #7
              Something tells me my entire logic of how I'm going about this is wrong. Some pro please help me accomplish this ?

              Comment


                #8
                Just what EvilDrWong said - it sets bHidden depending only on last pawn it checks. To fix it:

                Code:
                
                bHidden=true;   //we're assuming we won't hit anything
                
                foreach VisibleCollidingActors(class'Pawn', P)
                {
                   if (VSize(self.Location - P.Location) < HiddenDistance) // changed <
                  {
                  bHidden=false; //but we actually hit something
                  break;               //so we don't need to check others
                  }
                }
                
                //if we still didn't hit anyone, bHidden=true as above

                Comment

                Working...
                X