Find the center of an object

Hi,

does anyone know how to do that => If the character looks in the middle (-10 to 10 degrees) of an object, the object’s color should change.

Dot Product look direction & the direction to the object. Dot goes from -1 <-> 1, use ACOSd to work with degrees if that’s more convenient. When you hit the desired threshold either switch materials or use a dynamic material instance to adjust the color.

3 Likes

Try this:

My Products

3 Likes

To make both of the solutions above work, the pivot points of both objects need to be in the center…

1 Like

I did it, but still not the desired result. The color should change when the arrowhead of the character points to the center of the object.

Angle

What is not working? I mean, you need script for the material change:


Or a dynamic material instance. This can be set up better so we do not spam the whole thing on Tick, ofc.

2 Likes

Would this also work in “ThirdPerson” version? You use camera and not arrow. I want the color to change when the character looks at the center of the object. The camera shouldn’t have any effect.

Yes, it will work with anything. Use the arrow’s location and forward.

1 Like

thank you very much, worked very well! :slightly_smiling_face:

1 Like