Results 1 to 7 of 7
  1. #1
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Posts
    265

    Default Directional Trace

    Sorry about the stupid question, but how would I perform a directional trace(To the left, or right)?

    This works all fine and dandy but the trace is unaffected by the pawn's rotation, so If I were facing forward the trace would trace to the right, but if I turned to face the right, the trace would still being going to the right, going "forward" to my rotation.

    Code:
    TraceStart = Pawn.Location - vect(0,0,10);
    TraceEnd = TraceStart + vect(0,-30,0);

  2. #2
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,250

    Default

    So you want the trace to always go in the direction you are facing?

    Code:
    TraceStart = Pawn.Location;
    TraceEnd = TraceStart + vector(Pawn.Rotation) * dist; //dist is how far you want your trace to go, vector() returns a normalized vector with a length of 1
    2B || !(2B)

  3. #3
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Posts
    265

    Default

    Quote Originally Posted by UnrealEverything View Post
    So you want the trace to always go in the direction you are facing?

    Code:
    TraceStart = Pawn.Location;
    TraceEnd = TraceStart + vector(Pawn.Rotation) * dist; //dist is how far you want your trace to go, vector() returns a normalized vector with a length of 1
    That isn't the problem, I want to trace to go directional to the player (Left or Right), begin affected by the direction the player's facing.

  4. #4
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,250

    Default

    Okay, well that means the vector for the direction you are searching has a dot product of 0 with vector(Pawn.Rotation). I assume you don't want to trace up or down so that vectors z component will be 0. Now to get a vector that is orthogonal all you have to do is swap x and y and multiply either x or y by -1.

    Whether your vector goes to the left or the right depends on which component got multiplied by -1.

    Code:
    TraceStart = Pawn.Location;
    
    dir = vector(Pawn.Rotation);
    //swap x and y
    temp = dir.x;
    dir.x = -dir.y; //to the left
    dir.y = temp;
    
    dir.z = 0.0f;
    dir = normal(dir); //renormalize as we have nulled the z component
    
    TraceEnd = TraceStart + dir * dist; //dir is the new vector for the direction, either left or right; dist just like before
    2B || !(2B)

  5. #5

    Default

    Code:
    RightVector = Normal(vector(Pawn.Rotation) cross vect(0, 0, 1));
    or

    Code:
    local vector X, Y, Z;
    GetAxes(Pawn.Rotation, X, Y, Z);
    Using Y as left/right.

  6. #6
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,250

    Default

    Haha, why did I not think of this simple approach?
    2B || !(2B)

  7. #7


 

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.