Yea another Error

So, my game is again broken…
Yea i wrote after the function win()
goal.addEventListener(‘collision’, win);
Just take a look at my Script i wrote:
Url:
https://www.code3dgames.com/3de/#B/lVhtU9s4EP7Or1DzJc41OO90DmhnKE1p5yhlAm1v5uamo9hKrGJbPkkhTRn+++1K8ltiKDCZxN59JO0++yKJ47kIN2+Oe+Zn71gFkmeaKBm8bvV0JBnzf6gW6K1iG5FFG8WbEW/2COn1yCUiAkUU05qnSwVSI/qhfItTPk0SQV6Tdg8fYLL2UQNoLeQNkwaWWdV3K7ID7GLXESMtFbCUtQhXZB0xyYjSq8WC8JSIlSRLmjCy5nFMIpplLD2EgbdUEjMIZk/Zulj6CmVeB60xah98OJP0luuNh7jrD7Pp1P/KAi3kyCP9Ltkf9OG7TzpmEM67iKmGae/w9yqiIVBwSLRcsfscEfNlpN3KdsaTZM5Zqs9R4bXXEdesDbP6w4opNAw9M7JT8z0A9yR1zsPKijFFdORIyJ2lKgOjZ1Rz5H3N01CsfZ6mTH7joY5Iryb7wHCd3Fy7Qs3eSybNhPyWnRqt92rSrS7SJQP49OHPeGCn8DOhOChT/xfMNun3685ZUN07ydIQIipbJJR07VxE75xRxluRamFdDiB7iwDnY2uWf2Pzs/OZ03h3NNWcxpwqFyJjbT4Qo3/FfzFvh69uA11maCiCVQKR9LG4fJNv4WnE49ArJg1FMo0ZgsyIBnZgWa9v6OuSYZ3BWIibE92Qi5iE8OlsOQD5J9afaOazlM5jFgIX6GfO8R/uj1xdn8yuyenndx8vzsjnC5h8Si6mf1+T848X0wK2V2SvgokgZiZhFRYMauYUiszI38JTIRVUhk6Mj7l8KahDn8ETSvckQ9fhyQltPaBmsUoD5Ka6KLmr1pOqhfnz/AcQM3rn5RwXuGE9kQVvKLuxGWXh9bBMgOSJK/sqKKDKFLtYFww7nSoLd5gbs1XQygVNr2TqBh3t3dedtowWLkNgM1bz5CrD1nfGRMK03HgDzB2oyeGgaEyBuN0qhk9MRZeRSJefqGYSCsG7C0Qs5CFpSxa2bTWY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3fAdgzXnV/mqtOHYjeMlRtm3uQruP0m4CqroH4+hLLW1HAVWBVpALCRdQlNykbz+z1ue5f7B4D/gr5J+tLNXRR38U+s/wE=

I love these long Url’s :sweat_smile:

If you check the JavaScript console, you’ll see:

Uncaught TypeError: Cannot read property 'addEventListener' of undefined
    at VM59 code.html:152

We try to define goal up on line 35:

var goal = addGoal();

But… it does not actually assign goal because the addGoal() function does not return a value:

function addGoal() {
  shape = new THREE.CubeGeometry(100, 2, 100);
  cover = new THREE.MeshNormalMaterial({wireframe: true});
  var goal = new Physijs.BoxMesh(shape, cover, 0);
  goal.position.y = -50;
  scene.add(goal);
}

You have everything perfect in that function. It is only missing a return value, which you should add at the bottom of the function:

function addGoal() {
  shape = new THREE.CubeGeometry(100, 2, 100);
  cover = new THREE.MeshNormalMaterial({wireframe: true});
  var goal = new Physijs.BoxMesh(shape, cover, 0);
  goal.position.y = -50;
  scene.add(goal);
  
  return goal;
}

With that, it should work.

-Chris

yikes…
my Url has nothing Included!
https://is.gd/FtQt87