So I am mathematically calculating the distance between a character and a target location. Dealing with positive numbers is no problem, but I am unsure of how to manage the negatives. The Map is placed at 0,0,0 so there will be equally much negative vectors as positive, so I need to work this out.
Is there perhaps a way to get the total amount between two numbers other than subtracting (since that doesn't work with negatives)
I tried doing abs() to make it all positives, but there a logic issue with that. The calculation is not correct if one is positive and the other negative, IE the character is at -1000 and the target is at x 1000, it believes the target is reached since it subtracts 1000 with 1000.
Or should I perhaps do some conditions, and subtract double the amount (to accomodate being negative)? It will have to be a ton conditions though.
Edit: I think I've gone about it the wrong way, I'll just subtract the negatives then do an abs() on the result.



Reply With Quote



Bookmarks