Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by paulh

Hi

Is there anyway of setting the gravity centre?

So all entities currently fall DOWN the screen, say i wanted to move the gravity value so :

1. They fell up the screen.
2. Fell towards the centre of the screen.

and update that dynamically, whats the best route for doing that?

1 decade ago by alexandre

Do you want uniform gravity (same for all entities regardless of location) or local (pulls units towards it)?

1 decade ago by paulh

I'd like to know how to do both, if possible?

1 decade ago by alexandre

For uniform, change ig.game.gravity at any time in game. Movement calcs will be updated accordingly.

(untried) For localized, I'd use box2d, sensors, and forces. This would allow one to have multiple gravity fields within a scene, with forces applied to bodies in range of one or more fields. You would then set the containing entities' gravityFactor to some value between 0 (full gravity field control) and n (gravity fields and world gravity effects combined).

1 decade ago by paulh

Oh :-( im not using box2d yet!

So how would i set ig.game.gravity to say, the centre of the screen?

1 decade ago by alexandre

Bypassing box2d, then... if you only need one center of gravity (cog), then you'll need to apply gravity acceleration to each entity, setting its accel property accordingly, as it gets pulled towards the cog. Someone ought to do a plugin for this... ;)

1 decade ago by alexandre

paulh, may be too late but in case you still need it, I just posted a local gravity plugin in Code section. FMI check blog.
Page 1 of 1
« first « previous next › last »