To figure out how to keep the chest from flying off into infinity, we need to save where it started and keep checking if it has moved far enough before stopping it.
- Create a new variable above the
start
function calledstartingPosition
which is equal tonew Vector3()
- In the
start
function, add a line that sets yourstartingPosition
variable to this entity’s world position.
this.startingPosition.copy(this.entity.worldTransform.position)