Skip to content
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

Additional examples with PixiJS? #17

Closed
bpkennedy opened this issue Dec 26, 2019 · 4 comments
Closed

Additional examples with PixiJS? #17

bpkennedy opened this issue Dec 26, 2019 · 4 comments

Comments

@bpkennedy
Copy link

Hey, really like the project! I'm trying to use this with a Pixi.js game. Having trouble understanding how to use sprites from pixi for the steering behaviors (specifically seek) and your examples are generally using three.js.

Could you provide a basic demo with pixi?

@Mugen87
Copy link
Owner

Mugen87 commented Dec 26, 2019

Hey, really like the project!

Thank you for the feedback! Unfortunately, I'm not familiar with pixi.js so I'm not sure how easy it is to combine both projects.

The basic idea of using this library is to implement game logic via Yuka's game entity concept. A game entity can have a so called render component which is basically an object primitive of a rendering engine. For example an instance of THREE.Mesh or PIXI.Sprite.

You just copy the transformation of your game entities to your render components each simulation step and ensure they are nicely drawn by your selected rendering engine. This works properly with three.js or Babylon.js however pixi.js is problematic since it's a pure 2D engine. Meaning it defines the sprite's position in pixels/screen coordinates. In Yuka, three.js and Babylon.js, the position values are defined in world units/world coordinates.

I actually don't know how to bring these two different concepts in a meaningful way together with Pixi.js. I've created a fiddle to illustrate the issue:

https://jsfiddle.net/s6mctj3r/4/

@bpkennedy
Copy link
Author

Interesting! I do see in the fiddle that the sprite's are moving around a bit, although I don't quite understand how. I will spend some more time fiddling with them and see if I can understand better. Thanks for illustrating the issue!

@Mugen87
Copy link
Owner

Mugen87 commented Dec 26, 2019

I do see in the fiddle that the sprite's are moving around a bit, although I don't quite understand how.

The problem is that the game entities position values lie in a range let's say [-50,50] world units. Pixi interprets these units as screen coordinates/pixels which usually have a different range (check the app.screen object). Hence, you see only a minor movement.

@Mugen87
Copy link
Owner

Mugen87 commented Dec 27, 2019

Closing. After some considerations we are not going to add (official) pixi.js examples. The implementation of Yuka is just not designed for a 2D game. The combination might work in certain scenarios but it's best to use a 3D engine.

@Mugen87 Mugen87 closed this as completed Dec 27, 2019
@Mugen87 Mugen87 changed the title Additional examples? Additional examples with PixiJS? Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants