Local gravity i.e. Planets/Moons

Get help using Construct 2

Post » Mon Nov 21, 2011 11:45 pm

Well you made a lot of mistake
The bigger one is that you forgot to set world gravity to 0 (easy to miss)
Others are in how you use foreach and how you nest things
Also you added gravity to mass at some point
And you didn't need to use an Array object, global variables are better
etc, etc, etc

Just compare I hope you'll understand
gravity.capx
Last edited by Yann on Sun Sep 14, 2014 10:59 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Nov 22, 2011 12:23 am

I could have sworn I'd set the gravity to 0. Looking at this, I realise I knew nothing about sub-events and blank events containing actions. Need to figure out how that works. Starting to think I've jumped into the deep end, but this really is fascinating. The physics engine is purely used for collisions and forward momentum. Everything else is handled by maths. It's a lot to get my head around, but I'll do my best!

Thank you for all your help on this. I'll have a tweak on the figures until I understand what each one does, then I'll have a look at improving the graphics and making a game out of this.

Thanks again!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Mar 13, 2012 1:45 pm

OK, I just saw this thread (sorry for reviving it) but I feel I must contribute:

Lets say you want a crate to be pulled by one or more moons ;)

-Set the world gravity to 0
-Physics behaviour in all the objects in with the gravity force will act (in this case, the crates).
-Events:
     Each 0.5 seconds (for better performance)
     Apply Force On CRATE Toward position MOON.X, MOON.Y->GLOBAL_VARIABLE * (CRATE.mass + MOON.mass) / ((CRATE.X - MOON.X)*(CRATE.X - MOON.X) + (CRATE.Y - MOON.Y)*(CRATE.Y - MOON.Y))


(I have optimized the gravitation formula a bit)
GLOBAL_VARIABLE should be replaced by any global variable you want, it can (and probably should) even replace the mass+mass on top, and will probably be a BIG value.

Hope it helps.
B
9
S
1
G
2
Posts: 15
Reputation: 2,082

Previous

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul and 20 guests