Announcement

Collapse
No announcement yet.

Need help to find the angle or direction of the character compared to the other character

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

    Need help to find the angle or direction of the character compared to the other character

    I have a player character and a horse character. I could stand to its left/right/rear and use a sphere trace to detect the horse. Based on the sphere trace, I'm trying to figure out if I'm on the horse's left/right/behind/front. Based on knowing that I am planning to play the correct mount animation.

    I've posted two images so that you can visualize the problem and a graph that shows my attempt.

    Click image for larger version

Name:	Capture.PNG
Views:	103
Size:	358.3 KB
ID:	1722552



































    Click image for larger version

Name:	Capture2.PNG
Views:	71
Size:	142.4 KB
ID:	1722553

    #2
    You could use DOTProduct & Vectors. Search for a DP chart. Basically its: -1 opposite / opposing, 1 facing same direction, 0.5/-0.5 perpendicular. However, it might just be simpler to attach 4 collision spheres to the horse (North / South / East / West)....

    Comment


      #3
      I know how to do it using box collisions. My cursor that you see in the middle of the screen is the selector. I can only interact with objects when my cursor is over it and I'm nearby.

      But I'm trying to solve this issue only using sphere trace and whatever other nodes can help me with this.

      Comment


        #4
        After some search, I tried this approach but it always returns zero. IF I only use the dot product part of it. It gives some values but sort of useless, since It doesn't tell me what I need.

        Click image for larger version

Name:	Capture.PNG
Views:	63
Size:	242.9 KB
ID:	1722655
        Last edited by Zeon0101; 02-18-2020, 03:28 AM.

        Comment


          #5
          Whats wrong with 4 collision boxes? You want to make life hard on yourself... - Ok, I can think of two ways to get this done. DOT-Product as mentioned. This works for sure. Its the technique fighting games use to react to a punch / kick and move in that direction. Search out YouTube for a tutorial as its too involved to go into here. The other option, is a detailed Line / Shape Trace to Bone / Face etc. Once you get a hit you compare it to a pre-prepared list of body parts that you store in arrays beforehand. That's all I can think of. Someone else will have to help otherwise, as I'm not sure what that code is above (its hard to view / low res).
          Last edited by EntrpriseCustomr; 02-18-2020, 03:08 AM.

          Comment


            #6
            A simple solution is: place one collision box around the horse for interaction then the following will work.

            if the impact normal is same as forward vector, you are hitting the horses front, if impact normal is same as right vector then it right, and if it's the opposite etc, works regardless of direction horse is facing.
            Click image for larger version  Name:	sides.jpg Views:	0 Size:	128.8 KB ID:	1722660
            Click image for larger version  Name:	sides2.jpg Views:	0 Size:	139.5 KB ID:	1722662
            Last edited by Basement Bob; 02-18-2020, 03:53 AM.

            Comment


              #7
              I ended up adding three box collision and ditched front collision for now. Then added a sphere trace for objects to detect only world static. If I use the existing one, it doesn't always work and sometimes instead of returning left/right/rear box collision string, it returns the horse's instance name I guess. So here how it looks. This seems to work mostly. I still have to try "Basement Bob"s approach.

              Click image for larger version  Name:	Capture.PNG Views:	0 Size:	177.6 KB ID:	1723165
              Last edited by Zeon0101; 02-19-2020, 03:35 AM.

              Comment

              Working...
              X