LookAt question (coding)

Hi guys!
Task: The button needs to look always to the camera

I really sucked in code )) but one of my friends give me this one

const Scene = require(‘Scene’);
const R = require(‘Reactive’);
const Time = require(‘Time’);
const Patches = require(‘Patches’);
const DeviceMotion = require(‘DeviceMotion’);

const TouchGestures = require(‘TouchGestures’);

// Use export keyword to make a symbol available in scripting debug console
export const Diagnostics = require(‘Diagnostics’);

// Enables async/await in JS [part 1]
(async function() {
const [bossNull, boss, camera] = await Promise.all([

let angle = getAngleBetweenVertices();

// Here if i moving around object its moving to the camera.
boss.transform.rotationY = degrees_to_radians(angle.z);

// if i add another axes its ruined and object work not well
// boss.transform.rotationX = degrees_to_radians(angle.y);

function normalizeAngle(angle){
    if (R.gt(angle, R.val(360))) {
        return angle.sub(R.val(360));
    if (R.lt(angle, 0)) {
        return angle.sum(R.val(360));
    } else return angle;

function getAngleBetweenPoints(cx, cy, ex, ey){
    var dy = R.sub(ey,cy);
    var dx = R.sub(ex,cx);
    var theta = R.atan2(dy, dx);
    return R.mul(theta, R.val(180/Math.PI))

function getAngleBetweenVertices(){
    return R.point(
        normalizeAngle(getAngleBetweenPoints(bossNull.worldTransform.position.z, bossNull.worldTransform.position.x, camera.worldTransform.position.z, camera.worldTransform.position.x)),
        normalizeAngle(getAngleBetweenPoints(bossNull.worldTransform.position.z, bossNull.worldTransform.position.y, camera.worldTransform.position.z, camera.worldTransform.position.y)),
        normalizeAngle(getAngleBetweenPoints(bossNull.worldTransform.position.x, bossNull.worldTransform.position.y, camera.worldTransform.position.x, camera.worldTransform.position.y))

function degrees_to_radians(degrees) {
    var pi = Math.PI;
    return R.mul(degrees, R.val(pi/180));


How to solve this problem? :frowning:

I think the easiest way to get billboarding is to use a particle system. For tap events, you’ll need to add a sphere or something else as the target.

Otherwise, maybe this thread will help you.


Thank you as always! try to figure it out :wink: stay tuned :smiley: