For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Does anyone know how or if "Extent" works in Trace?

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
Post Reply
User avatar
スマイル・ドラゴン
OldUnreal Member
Posts: 1263
Joined: Sun Feb 10, 2008 9:07 pm

Does anyone know how or if "Extent" works in Trace?

Post by スマイル・ドラゴン »

Code: Select all

native(277) final function Actor Trace
(
      out vector      HitLocation,
      out vector      HitNormal,
      vector          TraceEnd,
      optional vector TraceStart,
      optional bool   bTraceActors,
      optional vector Extent
);
I would like to beable to perform a "cylindrical" style trace or atleast have some sort of bounds checking along the X and Y axis rather than just test a straight line upward.

Is this what "Extent" is for? Or is this variable broken and I need to perform multiple tests?

I'm trying to refine this code so instead of just producing a line it produces some sort of box like test instead:

Code: Select all

if( bReducedCrouchHeight ) //Prevent getting up if somethings in the damn way.
{
      StartTrace = Location;
      EndTrace = Location;
      EndTrace.Z += 64.0;
      Trace( HitLocation, HitNormal, EndTrace, StartTrace, false);
}
“I am the dragon without a name.”
Ðàrk-_¦_-Ñïght.: / κυνικός Δράκων / スマイル・ドラゴン / Draco Nihil
User avatar
gopostal
OldUnreal Member
Posts: 1005
Joined: Thu Jul 31, 2008 9:29 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by gopostal »

There are probably better ways of doing it but what I always did was create an item that had the dimensions of what box/area/whatever you need to check is empty. Draw your trace and test spawn the item at the trace point. If it spawns then you have room and you can immediately destroy it and do whatever you need to do. If the spawn fails then something is encroaching.

For this usage I'd create a cylinder with whatever height you want to check and try to spawn it over the head of the player. That would tell you if you have room.

I'm curious though how the better coders here will tell you how to do this. I never felt like my way was very good.
I don't want to give the end away
but we're all going to die one day
User avatar
スマイル・ドラゴン
OldUnreal Member
Posts: 1263
Joined: Sun Feb 10, 2008 9:07 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by スマイル・ドラゴン »

Testing with a "if( Move(NewLoc) )" statement somewhat works but it's still not entirely perfect.

And I'd still would love to know about this "Extent" optional variable in Trace.
“I am the dragon without a name.”
Ðàrk-_¦_-Ñïght.: / κυνικός Δράκων / スマイル・ドラゴン / Draco Nihil
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by Bleeder91[NL] »

Extend does give some width to the Trace. An example is in the 227 RealCrouch code, where it checks for anything above the player to collide with, when trying to uncrouch:

Code: Select all

simulated final function bool TryToDuck( bool bCrouching )
{
      local vector Dummy,Offset,Start;

      if( !Level.bSupportsRealCrouching || bIsReducedCrouch==bCrouching )
            return true;
      if( bCrouching )
      {
            SetCrouch(true);
            return true;
      }
      // Make sure theres space to get up.
      Start = Location;
      Start.Z = Location.Z+CollisionHeight-0.01f;
      Offset.Z = ((CollisionHeight/CrouchHeightPct)-CollisionHeight);
      if( Trace(Dummy,Dummy,Start+Offset,Start,true,vect(1.f,1.f,0.f)*CollisionRadius)!=None )
            return false; // Wasnt enough space to uncrouch.
      SetCrouch(false);
      return true;
}
Though I'm not sure if it's actually a cylindrical or box radius.
Image
User avatar
スマイル・ドラゴン
OldUnreal Member
Posts: 1263
Joined: Sun Feb 10, 2008 9:07 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by スマイル・ドラゴン »

Also another question. TraceStart is a optional variable. Does this mean the TraceStart becomes the calling Actor's Location if it's not defined in the function call?
“I am the dragon without a name.”
Ðàrk-_¦_-Ñïght.: / κυνικός Δράκων / スマイル・ドラゴン / Draco Nihil
User avatar
Bleeder91[NL]
OldUnreal Member
Posts: 1062
Joined: Sun Oct 04, 2009 7:22 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by Bleeder91[NL] »

TraceStart defaults to Location, yes.
Image
User avatar
スマイル・ドラゴン
OldUnreal Member
Posts: 1263
Joined: Sun Feb 10, 2008 9:07 pm

Re: Does anyone know how or if "Extent" works in Trace?

Post by スマイル・ドラゴン »

Extent seems to work like it should in this instance, I finally got my crouching check to properly examine the surroundings.

Though another question arises, how does Extent work if you wanted to make a "fat" trace? Like, a hitscan weapon with a wide collision radius on the hitscan itself.
“I am the dragon without a name.”
Ðàrk-_¦_-Ñïght.: / κυνικός Δράκων / スマイル・ドラゴン / Draco Nihil
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Does anyone know how or if "Extent" works in Trace?

Post by []KAOS[]Casey »

Set extent to vect(WIDE_NUMBER,0.001,0.001). From what I understand "extent" is just a box/cube with the dimensions X/Y/Z when checking for trace hits. A large X and a small Y/Z should accomplish what you want.
Post Reply

Return to “UScript Board”