Hi everyone, I’m using dot product to know if I’m facing enemy, and I want to know I’ll still facing enemy if I move to the sphere location. Are there any ways to know before I move? Anyone could help? Thank you in advance.
Well you could move to the other sphere and not face the enemy. Whether you’re faceing the enemy or not isn’t related to where you are, it’s related to the rotation of your character.
If you mean that you move to the sphere location, but your rotation doesn’t change, it’s easy:
Calculate the same dot product, but this time use Sphere location instead of Character Location, and use the Forward Vector of the character, not of the sphere.
Thank you! I did as you said and calculate new forward vector by divide the sphere with my current location. And boom! I’m grateful to you!
Nice!
One remark though: when you subtract two vectors, you don’t have to get Rotation From X and Forward Vector, they just cancel each other out. Just normalize the subtraction result and it’ll be the same with no extra steps.
You’re right, thank you again!