Grow image element

How would I make it so if I am certain distance from a given entity, The 2d screen would grow to a certain size.

What I have now

var Grow = pc.createScript('grow');

Grow.attributes.add('doorEntity', {type: 'entity'});
Grow.prototype.initialize = function() {


// update code called every frame
Grow.prototype.update = function(dt) {
    let crosshair_position = this.entity.getPosition();
    let door_position = this.doorEntity.getPosition();
    let distance = door_position.distance(crosshair_position);

    if(distance < 2.0){
        if(distance > 2.0){

Can you also tell us what the current result is and what you would like to see differently?

It just does not grow. no errors in the game.

Just based on your mention that you’re using a 2D screen it makes sense that distance wouldn’t be affecting anything since it’s in screen space and not world space. Can you be a little more clear on the behavior you’re looking for and post the project for others to take a look?

Your mention of a crosshair in the code makes it a little unclear. Do you mean that when the crosshair is within 2 screen units of being on top of the entity, the screen should get bigger, or that when the player is physically 2 units away the screen should get bigger?