Having trouble with gravity

For questions about using Classic.

Post » Sun Jan 03, 2010 1:14 am

Is there a way to add Gravity to a sprite so that it attracts other things?
B
2
G
3
Posts: 16
Reputation: 882

Post » Sun Jan 03, 2010 1:27 am

Try Linkman2004's Gravitation plugin

viewtopic.php?f=2&t=4169&hilit=gravitation

Should be what you are looking for.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Sun Jan 03, 2010 1:39 am

I should have searched "Gravitation" Instead of "Gravity".

Thanks, this is exactly what I was looking for.
B
2
G
3
Posts: 16
Reputation: 882

Post » Sun Jan 03, 2010 8:24 am

You might try testing out the Custom movement behavior. Its got just about everything you would need to simulate gravity, as well as physics.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Jan 04, 2010 2:00 pm

[quote="newt":37202zbf]You might try testing out the Custom movement behavior. Its got just about everything you would need to simulate gravity, as well as physics.[/quote:37202zbf]

I have been trying to figure out how to use physics and custom movement for this for a week now.

It does not make much sense to me.
B
2
G
3
Posts: 16
Reputation: 882

Post » Wed Jan 06, 2010 10:36 am

Using the custom movement plugin, simply "accelerate" (through the custom movement --> set speed action) towards whatever point you want. It's possible to simulate complex gravity behaviour (eg, multiple points of gravity) with this method.

Edit: Here's an example where using families, you can achieve this:
[code:2mq84cok]
+ System: For each spaceyobject
-> Projectile: Accelerate speed : spaceyobject.Value('Mass')/((distance(spaceyobject.X,spaceyobject.Y, Projectile.X, Projectile.Y))^2) towards spaceyobject
[/code:2mq84cok]
Where you can have multiple objects with the family attribute "spaceyobject". The projectile will accelerate towards "spaceyobjects" according to the equation: (mass (arbitrary private variable held by all spaceyobjects))/(distance from projectile to object^2)

Because this occurs for each spacey object, you can achieve quite realistic (within reason) behaviour. You'll need "mass" values of somewhere around 25,000.
B
3
G
3
Posts: 46
Reputation: 967

Post » Wed Jan 06, 2010 2:05 pm

[quote="Stargoat":1och7wgt]Using the custom movement plugin, simply "accelerate" (through the custom movement --> set speed action) towards whatever point you want. It's possible to simulate complex gravity behaviour (eg, multiple points of gravity) with this method.

Edit: Here's an example where using families, you can achieve this:
[code:1och7wgt]
+ System: For each spaceyobject
-> Projectile: Accelerate speed : spaceyobject.Value('Mass')/((distance(spaceyobject.X,spaceyobject.Y, Projectile.X, Projectile.Y))^2) towards spaceyobject
[/code:1och7wgt]
Where you can have multiple objects with the family attribute "spaceyobject". The projectile will accelerate towards "spaceyobjects" according to the equation: (mass (arbitrary private variable held by all spaceyobjects))/(distance from projectile to object^2)

Because this occurs for each spacey object, you can achieve quite realistic (within reason) behaviour. You'll need "mass" values of somewhere around 25,000.[/quote:1och7wgt]

I feel like an idiot.

When I added custom movement to a sprite, and saw there were no options to change, I assumed it was not ready yet. Never occurred to me that they were all assignable actions.

Guess this is why I could never understand programming languages.

Thank you so much, while this does not affect my gravity issue just yet (as I will have to figure out how this all works), it has allowed me to set up movement the way I want.
B
2
G
3
Posts: 16
Reputation: 882


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests