[SOLVED] An entities variable is changing despite only being set once

I have an entities start position set on its initialization:

Pickup.prototype.initialize = function() {
    this.myStartPosition= this.entity.getPosition();
}

…later in the game I move the entity around and I want to set it back to its start position, however, when I access script.pickup.myStartPosition from another script, it returns its current position - not the start position.

It seems that this.myStartPosition is being updated all the time (with its current position). What am I doing wrong here? Something very obvious Im sure.

Cheers

Oh wait. I need to do:

this.myStartPosition= this.entity.getPosition().clone();

2 Likes