X3M's Forum Posts

  • Colludium The reason why it doesn't work is because the statement "this" is encapsulated inside the instance prototypes scopes. So it cannot pass the borders towards other functions, therfore you should pass it as a paramter if you're planning to make your own function outside the .prototypes. If it is a function of a library such as Box2D , which is the case here, you should assign it to a global variable declared outside the scopes.

    Like this:

    var _this;
    instanceProto.onCreate = function () {
    _this = this;
    this.gravFactor = this.properties[8];
    ....
    }
    
    Box2D.Dynamics.b2Island.prototype._InitializeVelocities = function(step, gravity){
     alert(_this.gravFactor);
    ....
    }
    [/code:348r2k3p]
    
    Use _this inside the Box2D functions
  • matriax Glad you got it working, are you making a minecraft like game ?

  • matriax The camera uses a native physics engine, it does not use Oimo or Cannon. The native engine doesn't mimic real life physics at 100%.

  • matriax Can you send me the capx please ?

  • matriax I did it for the meshes and I forgot to do it for the cameras , here if you take a look at the function :

    	Acts.prototype.RotateMeshBy = function (x, y, z) {
    		var mesh = this.runtime.scenes[this.properties[1]].getMeshByName("mesh" + this.uid);
    		mesh.rotation.x += cr.to_radians(x);
    		mesh.rotation.y += cr.to_radians(y);
    		mesh.rotation.z += cr.to_radians(z);
    	};
    [/code:3jgk9dvj]
    But for the camera it's : 
    [code:3jgk9dvj]
    	Acts.prototype.RotateCameraBy = function (x, y, z) {
    		var camera = this.runtime.scenes[this.properties[1]].getCameraByName(this.properties[0]);
    		camera.rotation = new BABYLON.Vector3(camera.rotation.x + x, camera.rotation.y + y, camera.rotation.z + z);
    	};
    [/code:3jgk9dvj]
    
    You can temporally fix it by changing it to :
    [code:3jgk9dvj]
    	Acts.prototype.RotateCameraBy = function (x, y, z) {
    		var camera = this.runtime.scenes[this.properties[1]].getCameraByName(this.properties[0]);
    		camera.rotation = new BABYLON.Vector3(camera.rotation.x + cr.to_radians(x), camera.rotation.y + cr.to_radians(y), camera.rotation.z + cr.to_radians(z));
    	};
    [/code:3jgk9dvj]
    
    It's line [b]481 [/b]inside the [b]babylonNewCamera/runtime.js[/b]
    
    Again sorry for these small overlooked mistakes, I've been quite busy lately with some life stuff, and I still need to finish some other projects that I've been working on. 
    I will revise the codes as soon as possible, they are not huge problems, just small mistakes.
  • matriax The camera cannot have a parent, I forgot to remove that function.

    MATAGUIRIS You should use the scene loader plugins, export your scene from Blender, 3DS Max or Unity 5 and load it inside C2

  • MATAGUIRIS Here is an example

    Here is a fully detailed explanation:

    As you know, obj models are widely available on the Internet, but the modellers can be sometimes noobs and they don't set the pivot to the center of the model or sometimes the scaling factor of the pivot is not 1. Or sometimes the obj can be composed of several meshes which is a problem. So to solve this problem I added an extra mesh which will act as a parent, you can see it if you set Debug to True in the OBJ properties.

    So when you import an obj model, you need to see if the debug mesh fits perfectly to the obj, if not then you should use those XYZ scaling and offset parameters to adjust fit the model.

    And finally you activate collisions for the mesh debugger.

    matriax Oh I see so it's for Nvidia only ?

  • matriax It would be better if you matched the scene skycolor (Clear color) with the fog color, your video looks smooth, is it a 60 FPS video ? what screen recorder are you using ?

  • Psychokiller1888 I've just added the On released conditions.

  • matriax Oh I didn't pay attention to it

  • matriax I forgot about those, I'll be adding them in the next update, now I'm working on some tutorials : https://x3mworks.blogspot.com/p/babylon ... rials.html

  • matriax The mouse lock works, but the camera does not exceed 360 degrees, the devs made it this way to simulate a human head , which cannot rotate 360 degrees like an owl for example. So you can look right and left but not back, if you wanna look behind you will need to step diagonally just like in real life.

    Also the mouse lock works better if you go to fullscreen mode.

    About the FPS problem, try setting the scene native gravity on the Z axis like (0,0,-9.8) this way the camera will drop forward, but then you will have to find a way to make the camera stand on the Z axis and not act as if its laying on the ground.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Another question...

    Can the camera collide with an obj-mesh object?

    Yes, you should activate collisons for both Camera and the object in events ( You can also activate camera collison via tab properties [Check Collisions => True )

  • Everything now is working fine.

  • Hmm thats actually tricky because of two main issues :

    1- The example uses the C2 Car behavior which is 2 dimensional, the car goes on X and Y axis, so if you rotate the models 90 degrees on X axis, you will have problems with the car behavior, it will drive on the air.

    2- The BabylonJS Camera has a fixed XYZ axis that cannot be changed, I can't make it to walk on the XZY axis.

    I've got this request before in this thread about making FPS games from top down view C2 design, but I couldn't make it to work because of the engine limitations and the incompatibily with the C2 XY behaviors.

    If you find any solution for this, please notify me.