Making a trace go through walls

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Undertaker989

New Member
Aug 13, 2003
39
0
0
Ok, I'm trying to modify the lightning gun to be able to shoot through walls. I tried to do so by inserting bCollideWorld = false; in the DoTrace function of the fire class. No dice.

Does anyone know how to make a trace go through walls? Am I not using the right variable?

bCollideWorld is located in the Actor class btw.

Thanks.
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
41
New Zealand
www.digitalconfectioners.com
bCollideWorld doesn't have much to do with the Trace function. Go look in the Chimeric website, they have tutorial/document on how you should do this.

Hmm I can't get to that website any more. Alright, what you will have to do is when you get the HitLocation from the first trace, you have to then do a calculation to skip past the wall. You cannot run traces in the void. For example, say your shooting against the wall, HitLocation comes back you add a vectorial sum to that HitLocation ... similiar to this text picture.

Code:
A |     | B
  ---C---

Basically A is the HitLocation and B is where you want the trace to continue. C is the vectorial summation (you of course have to get the Direction of the original trace as well to do the vectorial summation properly). A + C should be where B is. Then from B, you start another Trace there. This would simulate shooting through walls.

I am NOT going to give code for this, I believe here is enough information to get you going. (Sorry if I sound mean, but the last post I answered just demanded code)
 
Last edited:

Undertaker989

New Member
Aug 13, 2003
39
0
0
Dr. Wong: I tried using the traceactors as you suggested, but it didn't work. I guess it's b/c of what Snake said. Thanks for the help tho.

SolidSnake: ok...I'll work w/ that. Thanks for the kickstart.
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
Ok, I took a stab at calling 2 traces + the vector summation, here's what I did (all this code is pasted from my weapons fire class):

first I added a function to call a 2ond trace:

Code:
function CallSecondTrace (Vector HitLocation, Rotator Dir)
{
 local Vector StartTraceB;

 //calculated the start of the second trace, which is the hitlocation of the 1st trace
    //+ the directoin of the 1st trace * 100
    StartTraceB = HitLocation + vector(100 * Dir);

    //called the dotraceB function using my 2ond starting point..the
// DoTraceB function is basically a copy of the DoTrace function 
//without the calling of this function (to prevent infinite recursion).
    DoTraceB(StartTraceB, Dir);

}

I then called that function in the Dotrace function around this area of the function (I'm just pasting a small portion of the function for convienence purposes):

Code:
ReflectNum = 0;
    while (true)
    {
        bDoReflect = false;
        X = Vector(Dir);
        End = Start + tmpTraceRange * X;
        Other = Trace(HitLocation, HitNormal, End, Start, true);
        CallSecondTrace(HitLocation, Dir);


        if ( Other != None && (Other != Instigator || ReflectNum > 0) )
        {
            if (b


Everything compiled ok, but the gun didn't shoot through walls. I am sure its b/c I'm not doing the vector summation (the 'C' portion of your diagram). Do you have that tutorial from Chimeric saved to your HDD? I'm really trying to get this working.

Thanks.
 
Last edited:

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
41
New Zealand
www.digitalconfectioners.com
I'm not sure on your calculation on StartTraceB there, I would do StartTraceB = HitLocation + 100 * Vector(Dir); although I am not so sure if the results would be the same.

I would also call the CallSecondTrace function if the inital trace hit worldgeometry as well. What do your logs say? If you haven't logged, some good logs to take note of is HitLocation, Dir and so forth. 100 units may also not be enough, as the trace may start in void, which will cause the Trace to fail.
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
OK, I just tweaked the class and both the CallSecondTrace and DoTraceB functions are being called. The only problem is that in the game, the lighting fire is sporadic instead of simply straight. Let me snap a video of it so you can see what I'm talking about:

Here's a 1.5MB vid

here's the code:
Code:
function CallSecondTrace (Vector HitLocation, Rotator Dir)
{
 local Vector StartTraceB;

 //calculated the start of the second trace, which is the hitlocation of the 1st trace
    //+ the directoin of the 1st trace * 100
    //StartTraceB = HitLocation + vector(100 * Dir);
     StartTraceB = HitLocation + 100 * Vector(Dir);
    //called the dotrace function using my 2ond starting point
    DoTraceB(StartTraceB, Dir);
 Log("CallSecondTrace Is Being Called");
}

called in Dotrace here:
Code:
ReflectNum = 0;
    while (true)
    {
        bDoReflect = false;
        X = Vector(Dir);
        End = Start + tmpTraceRange * X;
        Other = Trace(HitLocation, HitNormal, End, Start, true);

        if (Other.bWorldGeometry)
        {
        CallSecondTrace(HitLocation, Dir);
        }

        if (

keep in mind that the above is just a portion of the DoTrace Function to give you an idea of where I'm calling it. It is calling the function and you can see in the video @ least a 2ond trace is being done...its just a matter of getting the 2ond trace to go in the right direction.

As in my previous post, the DoTraceB function is the same as the DoTrace function w/o the code to call my function added to it (to prevent infinite recursion that crashed the game on me ;) ) .
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
41
New Zealand
www.digitalconfectioners.com
Alright, I'll fiddle with this myself and see what I get on my own. What I suggest trying however is to make a new actor which instances this, that way you'll really understand exactly what is going on. This is largely how I debug a lot of my problems and solve things like this.

What I usually do, is make a pointer. Basically it is just an actor with the bHidden=false on. It doesn't do anything on it's own.
Code:
class Pointer extends Actor;

defaultproperties
{
  bHidden=false
}
When dealing with trace functions and debugging, I usually spawn the Pointers at where the start of the trace is called and where the end of the trace is called. That way I can visually see exactly what is going on, and the bonus is, is that these actor's don't move or dissappear, so you can take your time and figure out what is going on in the trace. Try that, and if the pointers are going where they shouldn't be going then it's good sign that the traces that you are calling aren't going where you want it to.

Another way to do this is to make an actor, which does essentially the same thing. So in your case, just make the actor do a trace, calc and then do a secondtrace. This way, the code is cleaner and will also show if any of the code before hand is stuffing with the code you've put in.

I'll experiment with this and see what I come up with.
 

Undertaker989

New Member
Aug 13, 2003
39
0
0
Thanks...

I'm going to create a pointer tomorrow to see what that gun is doing. I didn't know you could make visible pointers...that helps out alot!