Making an Object turn to look at another Item over time


Here is the code I used to try have it turn smoothly, but it doesnt work as position cant equal to direction. Is there a way to have an object turn smoothly to face another object?

Hi @Bunny,

This is a super-tricky problem for something that seems like it should be so simple :blush:

I can’t think of an easy way to do this in CoBlocks (if at all). In Scripting we can use the RayCast feature to identify when an object can “see” another object, so we can turn until the object “sees” the Camera. See below for a remixable example:

Note that the position of Items in CoSpaces have their Z-axis co-ordinate at the bottom of the item, so most items won’t “see” the Camera because it is positioned 1.7m off the ground, hence, I’ve attached an invisible Cuboid to the Camera in the above example so that it will be seen.

Hope this helps! Let me know if you have any further questions.

Geoff @ TechLeap