Git Product home page Git Product logo

Comments (10)

jacklaplante avatar jacklaplante commented on May 27, 2024 1

Ya my current server uses websockets. It's very simple though. It essentially just relays the player's position to all the other players. But I need to figure out how to represent the world on the server side especially if I want to add AI. I will look into running three.js on the server side. It probably won't be the most efficient solution but at least it would allow some code parity.

Yuka looks really cool for what I'm trying to do. I'm excited to try it!

from yuka.

Mugen87 avatar Mugen87 commented on May 27, 2024 1

Actually, if I just use a nav mesh with Yuka could I skip using three entirely?

Yes, at least on the server side. I don't think using three.js or any other 3D engine is much helpful in addition to Yuka if your focus is just on implementing game logic.

BTW: The API style and math classes are quite similar to three.js. If you already know three.js, it should be a bit easier to get familiar with Yuka.

from yuka.

jacklaplante avatar jacklaplante commented on May 27, 2024 1

I can confirm that this works now, I just needed to reinstall yuka (maybe the version number should be increased)

Thank you @Mugen87 !

from yuka.

Mugen87 avatar Mugen87 commented on May 27, 2024

Some context: https://discourse.threejs.org/t/i-need-ideas-on-how-to-add-enemies-in-my-multiplayer-game/11006

Well, Yuka is just a bunch of classes with no rendering dependencies. So it's actually very easy to import Yuka into a node.js application and implement game logic. A very basic setup would look like so:

const YUKA = require( 'yuka' );

const entity = new YUKA.GameEntity();

setInterval( () => {

	entity.position.x += 1;

	console.log( 'New position:', entity.position );

}, 1000 );

This would update the game entity once per second. However, Yuka does not provide any kind of multiplayer/networking features you would normally find in a game engine. Writing a game server and the respective protocols is very difficult. So this would be a project of its own^^.

If you are interested, I suggest you start with studying how WebRTC and WebSockets work. Maybe you can build something on top of these Web APIs.

from yuka.

jacklaplante avatar jacklaplante commented on May 27, 2024

Actually, if I just use a nav mesh with Yuka could I skip using three entirely?

from yuka.

jacklaplante avatar jacklaplante commented on May 27, 2024

Hey @Mugen87 I've hit a snag with running Yuka on my node server. I'm getting this error when I try and load a NavMesh.

ReferenceError: fetch is not defined
    at Promise (C:\Users\jack\bowdown\server\node_modules\yuka\build\yuka.js:18666:5)
    at new Promise (<anonymous>)
    at NavMeshLoader.load (C:\Users\jack\bowdown\server\node_modules\yuka\build\yuka.js:18664:11)
    at Object.entities.init (C:\Users\jack\bowdown\server\entities.js:15:12)

I think Fetch is a browser API and doesn't work in node. I'm going to try and see if I can fix this myself (I've never contributed to an open source project and I would like to) But any advice you have would be helpful.

from yuka.

Mugen87 avatar Mugen87 commented on May 27, 2024

Try it with this npm package:

https://www.npmjs.com/package/node-fetch

We also use it in our unit tests which are executed in a node environment.

from yuka.

jacklaplante avatar jacklaplante commented on May 27, 2024

node-fetch doesn't seem to allow the use of relative urls. So I would have to also set up a local webserver just to serve the navmesh. I'm looking into other possible approaches. I'm thinking fs.readFile might be my best bet. But that doesn't return a Promise so it would require some rewriting in Yuka

from yuka.

Mugen87 avatar Mugen87 commented on May 27, 2024

61f2aaf introduced NavMeshLoader.parse(). You can now use the API like so:

const data = fs.readFileSync( path.join( __dirname, '../../../assets/navmesh/glb-embedded/navmesh.glb' ) );
const loader = new NavMeshLoader();
loader.parse( data.buffer ).then( ( navMesh ) => {
expect( navMesh ).is.an.instanceof( NavMesh );
expect( navMesh.regions ).to.have.lengthOf( 5 );
expect( navMesh.graph.getNodeCount() ).is.equal( 5 );
expect( navMesh.graph.getEdgeCount() ).is.equal( 8 );
done();
} );

I hope this makes the class more usable for you 👍

from yuka.

Mugen87 avatar Mugen87 commented on May 27, 2024

maybe the version number should be increased

I've actually increased it from 0.1.0 to 0.2.0.

from yuka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.