-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I run this in a server? #14
Comments
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. |
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! |
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 BTW: The API style and math classes are quite similar to |
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.
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. |
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. |
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 |
61f2aaf introduced yuka/test/unit_test/navigation/navmesh/NavMeshLoader.tests.js Lines 158 to 170 in e729830
I hope this makes the class more usable for you 👍 |
I can confirm that this works now, I just needed to reinstall yuka (maybe the version number should be increased) Thank you @Mugen87 ! |
I've actually increased it from |
I want to add AI controlled enemies to my multiplayer three.js game. How would I go about running this on a server?
The text was updated successfully, but these errors were encountered: