Page 1 of 1

Check if bones intersect player to get transparent

Posted: Thu Jan 14, 2016 4:14 am
by Veleran
I need some some help with a Pillar Pawn to check if Player is behind the pillar to reduce the pillar actor transparency so you can see the player when he is behind it.
I would like to check if player moves in the zone with two bones so you can not crouch or jump over the bones.

In the isometric view i use, imagine in the top view the position Player the gets hidden would be of the pillar,like 45 degrees diagonally right and up from the pawn.
So,lets say i want the offset to be 128 units from the pillar.
If you know an easier better way to to this you tell me please.

I would like an example if you can,with the following:
I was thinking having Orders like

Idle (checking if player is intersecting)
Transparent (change the alpha to semi transparent and continue checking player intersections,if not go back to idle)

string TraceToActor(string BoneName, float OffsetX, float OffsetY, float OffsetZ);
Traces a line from the specified bone to a point defined by a specified offset and returns the szEntityName of any pawn actor that it intersects. If it does not intersect with a pawn, it returns the string "FALSE". The offset is relative to the direction the pawn is facing. If the bone does not exist it returns "FALSE".
and then in transparent order

SetAlpha(float Alpha);
Set the transparency for the Pawn's actor.

Any examples would be appreciated,i would like to see again how you use that "if" thing and the true or false flags results.

I do not try another way to check this using clip or transparent triggers because clips would be too low on ground and you could jump over them while invisible brush triggers would receive stencil shadows and would have to add more and smaller of them for each pillar so any shadow on them would not be very noticeable.


Also, i am not sure yet how to check the list of those triggers instead of just one.
I mean the if(GetEventState("Pillar1Trigger1") = true)

or if(GetEventState("Pillar1Trigger2") = true)
i do not know how you put the "or" syntax either,if you tell me that it would be good to know because am still looking old demo sample scripts for examples.

Re: Check if bones intersect player to get transparent

Posted: Fri Jan 15, 2016 11:04 pm
by Allanon
Here is a script that you can attach to the pawn that will change the pawn's alpha when the player is within a certain distance and on a specific side of the pawn:

Code: Select all

{
    TRANSPARENT [false]

    Spawn[()
    {
        Console(true);
        LowLevel("Test");
     }]
   
    Test[()
    {
        self.ThinkTime = 0.1;

        // check if distance from player to pawn is less than 300
        d = DistanceBetweenEntities("Player",self.EntityName,true);  
        if (d < 300.0)  
        {
            // check if player is behind the pawn
            if (WhereIsPlayer() = 1)  
            {
                // if the pawn is not transparent change alpha to 128 making the pawn transparent
                if (TRANSPARENT = false)  
                {
                    SetEntityAlpha(self.EntityName, 128.0);  
                    TRANSPARENT = true;
                }
            }
            else
            {
                // if the pawn is transparent change alpha to 255 making the pawn not transparent
                if (TRANSPARENT = true)  
                {   
                    SetEntityAlpha(self.EntityName, 255.0);  
                    TRANSPARENT = false;
                }
            }
        }
        else
        {
            // if the pawn is transparent change alpha to 255 making the pawn not transparent
            if (TRANSPARENT = true)   
            {   
                SetEntityAlpha(self.EntityName, 255.0); 
                TRANSPARENT = false;
            }
         }
    }]
}
You will probably need to change the distance and side depending on the location of the pawn. If you wanted to get fancy and make it a generic script then you can add distance and side attributes to the pawn and have the script read and apply them. You could also add multiple sides by adding more WhereIsPlayer() checks.

I tried using the TraceToActor() function but it's hard to make a generic player script that works on all pawns.

Re: Check if bones intersect player to get transparent

Posted: Mon Jan 18, 2016 11:24 am
by Veleran
Thank you very much for the great script.I used it as it is and changed only the distance to 80 to match a pillar of diameter 64 and height 128 in iso camera 55 angle up and -135 degrees around.