Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 1: Moving Objects

Make the Chest Stop

You don’t have access to this lesson

Please register or sign in to access the course content.

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.

  1. Create a new variable above the start function called startingPosition which is equal to new Vector3()
  2. In the start function, add a line that sets your startingPosition variable to this entity’s world position. 
this.startingPosition.copy(this.entity.worldTransform.position)