Announcement

Collapse
No announcement yet.

Vector question left or right side hit detection

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

    Vector question left or right side hit detection

    Hello,

    I suck at math and especially vector math. I'm trying to detect if something is hit on the left or right side depending on its forward vector.

    How do I do this in the most easy way possible?

    I have tried with dotproduct between forward vector and hit vector but that gives insanely weird number, not positive or negative. I also tried making that result from dot product with acosd to get degrees but that also doesnt give me positive or negative, again weird numbers. o_O

    What I kinda want is like depending on forward vector it can go 180 degrees negative (left side) en 180 degrees right side (positive). So left side hit is for example -70 degrees en right side hit is for example +70 degrees.
    Last edited by WixZ; 10-22-2017, 12:19 PM.

    #2
    WixZ , You get the forward vector based on actor rotation ?
    Last edited by Mhousse1247; 10-22-2017, 12:31 PM.
    Website [ LINK ]
    Twitter [ LINK ]
    Support ! [ LINK ]

    Comment


      #3
      Originally posted by Mhousse1247 View Post
      WixZ , You get the forward vector based on actor rotation ?
      I use the forward vector from a mesh within the actor, this is because the mesh is interpolated and not always at the exact location of the actor. But ive tested this forward vector and it always rotates perfectly with the mesh and printing it's coordinates gives the expected results, so I don't see why it shoulnd't work.

      Comment


        #4
        Ah , I understand , you are using a mesh within an actor and modify it transform ( location or rotation ) in local space to make a fake simulation or animation.
        Website [ LINK ]
        Twitter [ LINK ]
        Support ! [ LINK ]

        Comment


          #5
          Ive been thinking and I think I know why I get the weird numbers...

          I think that what is wrong is maybe that the forward vector is also rotated and that adds to the angle between the forward vector and the hit normal. So I think I should probably like always use the forward vector as a null vector, like subtract the forward vectors angle from the final result or something?

          Comment


            #6
            Here is a way to do it , it cover all situations:

            Click image for larger version

Name:	test461.PNG
Views:	408
Size:	357.8 KB
ID:	1373645
            Website [ LINK ]
            Twitter [ LINK ]
            Support ! [ LINK ]

            Comment


              #7
              Oh man thanks a lot, it works!

              This is what I made using your solution:

              Comment


                #8
                Glad it helped
                Website [ LINK ]
                Twitter [ LINK ]
                Support ! [ LINK ]

                Comment

                Working...
                X