Jump to content

Collision not working locally?


yfVivien
 Share

Recommended Posts

Hey,

First time playing around with Babylon, it is awesome!!! But drives me crazy too LOL. I am trying to apply collisions onto boxes. It works in playground, but when I copy and paste the code into my local project, it stopped working. 

playground: http://www.babylonjs-playground.com/#RNKEAZ

local:

scripts included:

    <script src="http://cdn.babylonjs.com/2-5/babylon.js"></script>
    <script type="text/javascript" src="scripts/cannon.js"></script>
    <script type="text/javascript" src="scripts/babylon.fireProceduralTexture.js"></script>

code:

  function createScene(map) {
    scene = new BABYLON.Scene(engine);
    engine.enableOfflineSupport = false;
    fireTexture = new BABYLON.FireProceduralTexture("fire", 256, scene);
    flame = new BABYLON.Texture("Fire.png", scene);

    createSkybox();
    createSun();
    createGround();
    // createBuildings(map);

    // createNPCMesh();
    // createPlayerMesh();
    createAvatar();     // create and attach camera


    var box0 = BABYLON.Mesh.CreateBox("box0", 1, scene);
    box0.position = new BABYLON.Vector3(10, 5, 5);

    var box1 = BABYLON.Mesh.CreateBox("box1", 3, scene);
    box1.position = new BABYLON.Vector3(-10, 5, 5);

    scene.collisionsEnabled = true;
    box0.checkCollision = true;
    box1.checkCollision = true;

    scene.registerBeforeRender(function() {
      box0.moveWithCollisions(new BABYLON.Vector3(-0.1, 0, 0));
    });

    return scene;
  }

 

 

Any ideas?

Thanks in advance ;) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...