Physics, "free fall", how to?

For questions about using Classic.

Post » Wed Feb 03, 2010 9:00 pm

I've been trying to make an effect like this:

You know, the bomb have free fall, but what I do is make a variable change with a timer, so when variable = 0, bomb goes up with X Speed = 0, when variable = 1, X Speed = X Speed - 1 and Y Speed decrease, when variable = 2, .... that process. But I don't know if there is a better method, I don't know, maybe an ecuation?

I've been coding enemies but never a kind of this. Seems pretty diffcult to me right now, so please, I need your help.

Thank you.
?When everyone feels hope at the same time, wonderful things can happen.
B
5
G
3
Posts: 67
Reputation: 1,059

Post » Wed Feb 03, 2010 11:10 pm

In the real world, gravity applies a constant force to an object, and (air resistance aside), an object probably won't slow down horizontally. How can we describe this behaviour in Construct? Simple.

Let's assume you're using the custom movemement plugin (not essential by any means), we'd probably have something that looks like...

[code:7yqzx6b2]
+ System: Always (every tick)
-> Projectile: Accelerate vertical speed : 200
[/code:7yqzx6b2]
and

[code:7yqzx6b2]+ (event that creates bullet)
-> gun: Spawn object Projectile on layer 1 (image point 0)
-> Projectile: Set speed : 400 towards 30 degrees[/code:7yqzx6b2]

This reads as: every tick accelerate at a rate of 200 pixels per second^2 towards the bottom of the layout, with initial condition of 400 pixels per second at an angle of 30 degrees whenever a bullet is created. This will give you very realistic and satisfying projectile motion.

Hope this helps. If you have any more trouble, maybe I could break it down further for you.
B
3
G
3
Posts: 46
Reputation: 967

Post » Thu Feb 04, 2010 1:53 am

you could also use platform behavior, set ignoring input on create and set vertical and horizontal speeds.

Make sure to set air deceleration to 0 in the platform behavior options.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Feb 04, 2010 3:12 am

[quote="madster":20w8pfug]you could also use platform behavior, set ignoring input on create and set vertical and horizontal speeds.

Make sure to set air deceleration to 0 in the platform behavior options.[/quote:20w8pfug]

I don't think this is a very good way to learn how to use Construct well.
B
3
G
3
Posts: 46
Reputation: 967

Post » Thu Feb 04, 2010 4:43 am

[quote="Stargoat":1nput60r][quote="madster":1nput60r]you could also use platform behavior, set ignoring input on create and set vertical and horizontal speeds.

Make sure to set air deceleration to 0 in the platform behavior options.[/quote:1nput60r]

I don't think this is a very good way to learn how to use Construct well.[/quote:1nput60r]

Actually, I've made grenades that way.

But yeah, if you just need a bullet that arcs towards the ground, why not just use Bullet behavior, spawn it at the angle you want, then every tick you turn it a little bit towards the ground?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Feb 04, 2010 5:19 am

[quote="Stargoat":1d1sn09a]In the real world, gravity applies a constant force to an object, and (air resistance aside), an object probably won't slow down horizontally. How can we describe this behaviour in Construct? Simple.

Let's assume you're using the custom movemement plugin (not essential by any means), we'd probably have something that looks like...

[code:1d1sn09a]
+ System: Always (every tick)
-> Projectile: Accelerate vertical speed : 200
[/code:1d1sn09a]
and

[code:1d1sn09a]+ (event that creates bullet)
-> gun: Spawn object Projectile on layer 1 (image point 0)
-> Projectile: Set speed : 400 towards 30 degrees[/code:1d1sn09a]

This reads as: every tick accelerate at a rate of 200 pixels per second^2 towards the bottom of the layout, with initial condition of 400 pixels per second at an angle of 30 degrees whenever a bullet is created. This will give you very realistic and satisfying projectile motion.

Hope this helps. If you have any more trouble, maybe I could break it down further for you.[/quote:1d1sn09a]

Thank you so much, that helped me a lot!!!
?When everyone feels hope at the same time, wonderful things can happen.
B
5
G
3
Posts: 67
Reputation: 1,059

Post » Thu Feb 04, 2010 7:02 pm

[quote="Stargoat":1n6a0lrx]I don't think this is a very good way to learn how to use Construct well.[/quote:1n6a0lrx]
why not? it's faster in both design and execution and yields the exact same numerical result.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Feb 04, 2010 8:02 pm

I agree, plus the solid attribute works with other behaviors, unlike physics.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Thu Feb 04, 2010 8:04 pm

[quote="madster":17ffi658][quote="Stargoat":17ffi658]I don't think this is a very good way to learn how to use Construct well.[/quote:17ffi658]
why not? it's faster in both design and execution and yields the exact same numerical result.[/quote:17ffi658]

Because it doesn't teach the... erm... "player" about events, which is where Construct's power lies. When the player is already fluent with events and program flow in Construct, maybe it would make sense to do it that way.

Additionally...
-is it faster at run time?
-It's not exactly hard to write those couple of events
-what's wrong with teaching players about physics at the same time as Construct?

[quote="deadeye":17ffi658]Actually, I've made grenades that way.

But yeah, if you just need a bullet that arcs towards the ground, why not just use Bullet behavior, spawn it at the angle you want, then every tick you turn it a little bit towards the ground?[/quote:17ffi658]

That'll give you an arc, but it won't look or behave "naturally". Also, bullet behaviour doesn't have an explicit "accelerate" action. I think bullet behaviour is a tad more efficient than custom movement, but it's far less versatile.

[quote="newt":17ffi658]I agree, plus the solid attribute works with other behaviors, unlike physics.[/quote:17ffi658]

My example used the Custom Movement plugin.
B
3
G
3
Posts: 46
Reputation: 967

Post » Thu Feb 04, 2010 9:51 pm

[quote="Stargoat":geydqowe]Because it doesn't teach the... erm... "player" about events[/quote:geydqowe]
There is this misconception in development that you should do everything the "hard" and "true" way. That is not true at all. If you're looking to learn then yeah you should go learn events. If you want to get something done, then the easy way that works is just as good.
I assume you meant "the creator" and not "the player", as the player doesn't need to know (and shouldn't know) anything about events.

[quote:geydqowe]
Additionally...
-is it faster at run time?
-It's not exactly hard to write those couple of events
-what's wrong with teaching players about physics at the same time as Construct?
[/quote:geydqowe]
-Its faster as the plugins are C++, not interpreted events. It probably doesn't matter, though, at this scale.
-If it's not hard to write the couple of events... then why the fuzz about it? why do more work than needed?
-what is wrong is teaching people to always take the longer road to a destination ;) bad practice!

Custom movement would also be a good idea, it has gravity(by way of force) too IIRC
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests