How to use cursor-target addHoverFunction?

how can we use .addHoverFunction(f) specified in documentation for players? Can you give a simple code to console log a message when the cursor is pointed at an object for 2 sec?

start: function() {
    this.hovering = false;
    this.hoverTimer = 0.0;

    this.object.getComponent('cursor-target').addHoverFunction(() => this.hovering = true; );
    this.object.getComponent('cursor-target').addUnHoverFunction(() => this.hovering = false; this.hoverTimer = 0.0; );
},
update: function(dt) {
    if(this.hovering) this.hoverTimer += dt;
    if(this.hoverTimer >= 2.0) {
        this.hovering = false;
        this.hoverTimer = 0.0;
        // Do anything else here...
    }
}

I didn’t test this, hope it works

So I tried to modify the animation example

}, {
    start: function() {
        this.anim = this.object.getComponent('animation');

   

    this.hovering = false;
        this.hoverTimer = 0.0;

        this.object.getComponent('cursor-target').addHoverFunction(() => this.hovering = true; );
        this.object.getComponent('cursor-target').addUnHoverFunction(() => this.hovering = false; this.hoverTimer = 0.0; );
    },

    update: function(dt) {
    if(this.hovering) this.hoverTimer += dt;
    if(this.hoverTimer >= 2.0) {
        this.hovering = false;
        this.hoverTimer = 0.0;
        this.anim.play();
    }

});

terminal gave me these syntax errors

Yeah, there’s a } missing
Visual Studio code should probably be complaining about that :slightly_smiling_face:
There are auto-formating plugins and syntax checkers (also linters) for Visual Studio Code, make sure to install those, makes life a lot easier

Ooh I usually use vscode but in hurry I edited it in notepad :joy:
Now not even the scene is loading.