So I have spent a month working on my very own 3d game. It’s my first 3d game and I’m very excited to do it. I’ve only ever made 2d games so this is all new to me. I was hoping that someone on here could possibly help me. This is the file that controls my movement and terrain.
let createGameScene = function (canvas, engine) {
// Create scene
let scene = new BABYLON.Scene(engine);
scene.gravity = new BABYLON.Vector3(0, -.1, 0);
scene.enablePhysics(scene.gravity, new BABYLON.CannonJSPlugin());
// Create camera
let camera = new BABYLON.UniversalCamera(“Camera”, new BABYLON.Vector3(2, 2, 2), scene);
camera.attachControl(canvas, true);
camera.setTarget(BABYLON.Vector3.Zero());
// 87 corresponds to ‘w’
// 83 corresponds to ‘s’
// 65 corresponds to ‘a’
// 68 corresponds to ‘d’
camera.keysUp.push(87);
camera.keysDown.push(83);
camera.keysLeft.push(65);
camera.keysRight.push(68);
camera.speed = 1;
camera.fov = 0.8;
camera.inertia = 0;
camera.ellipsoid = new BABYLON.Vector3(1.5, 0.5, 1.5);
camera.checkCollisions = true;
camera.applyGravity = true;
camera.collisionsEnabled = true;
// Create lights
let light = new BABYLON.HemisphericLight(“myLight”, new BABYLON.Vector3(1, 1, 0), scene);
var ground = BABYLON.Mesh.CreateGroundFromHeightMap(“ground”, “./unnamed.png”, 50, 50, 10, -5, 9, scene, false , (mesh) => {return;})
ground.checkCollisions = true;
ground.collisionsEnabled = true;
return scene;
};
export {
createGameScene
};
In this, I have a 3d terrain and it runs perfectly fine. However, When I try to walk over the mountains it recognizes that as a collision and it won’t let me walk up a mountain. I would love if I could get my character to be able to walk up the mountains without struggle. Also, How would I add a jump function to this. I have to move in all directions except up. If someone that thinks that they could help sees this please do. I’m looking forward to making this game and I would like to fix all the kinks before the end of this week so that I can finish the map and start working on the game mechanics.