Announcement

Collapse
No announcement yet.

[Solved] Distance To - positive and negative values

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

    [Solved] Distance To - positive and negative values

    I am trying to get a distance to an actor in the world. The problem is that the value is always positive. If the player is getting closer to the actor I want the value to be positive but if the player has passed it I want the value to be negative. This should depend on the world rotation of the object. How to achieve this?
    Click image for larger version  Name:	Distance.png Views:	1 Size:	6.7 KB ID:	1452960
    EDIT: Ignore the spelling error

    #2
    Distance is always positive because you're describing the magnitude of something. You'd need distance and some kind of angle reference, to determine if it should be positive or negative.

    Comment


      #3
      Figured it out.

      Check if the Dot Product To is positive or negative. If positive then multiply Distance to by 1, if negative then multiply by -1

      Comment


        #4
        Originally posted by MacGowss View Post
        Figured it out.

        Check if the Dot Product To is positive or negative. If positive then multiply Distance to by 1, if negative then multiply by -1
        Or use sign(dotproduct)

        Comment

        Working...
        X