Making an object "fall" [FIXED] [New Problem]

For questions about using Classic.

Post » Fri Jan 09, 2009 9:33 am

Well, i used to do this in MMF2 using the Path Movement system, however since this doesn't exist anymore i'm having trouble doing it. My first thought was a loop that increments the Y location, however it's moving way too fast for the human eye to see, and i don't seem to find any "Wait" or "Sleep" type of action (possibly because the objects aren't multithreaded?)

I tried using TimeDelta as well, however this only functions properly when i put it in the Always condition, and i want this to be triggered whenever my character walks under it.

How would i do this?

EDIT, i solved it, if anyone else want help with this problem, pm me.

Now onto my second question, is it possible make an action only apply to a specific instance of an object without having to create different copies for each object i have?
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 10:31 am

[quote="Speljohan":1glf9nsj]Now onto my second question, is it possible make an action only apply to a specific instance of an object without having to create different copies for each object i have?[/quote:1glf9nsj]

Yes. Define the specific instance in your conditions.

For instance, if you have five enemies and you only want the one a bullet hits to be killed:

[code:1glf9nsj]
+bullet collides with enemy
->enemy: destroy
[/code:1glf9nsj]

This will only destroy the enemy that the bullet hits, because you defined the instance in the condition. On the other hand:

[code:1glf9nsj]
+bullet collides with bomb
->enemy: destroy
[/code:1glf9nsj]

This will destroy every enemy since Construct doesn't know which enemy you mean.

You can add as many descriptive conditions to define which instance to pick. Collisions, variables, expressions:

[code:1glf9nsj]
+enemy is overlapping trap
+enemy.Value('armor') is equal to 0
+enemy is visible
->enemy: destroy
[/code:1glf9nsj]

Out of all the enemies in the game, only the ones that meet all those criteria will be destroyed.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 09, 2009 10:41 am

[quote="deadeye":24xj4a1s][quote="Speljohan":24xj4a1s]Now onto my second question, is it possible make an action only apply to a specific instance of an object without having to create different copies for each object i have?[/quote:24xj4a1s]

Yes. Define the specific instance in your conditions.

For instance, if you have five enemies and you only want the one a bullet hits to be killed:

[code:24xj4a1s]
+bullet collides with enemy
->enemy: destroy
[/code:24xj4a1s]

This will only destroy the enemy that the bullet hits, because you defined the instance in the condition. On the other hand:

[code:24xj4a1s]
+bullet collides with bomb
->enemy: destroy
[/code:24xj4a1s]

This will destroy every enemy since Construct doesn't know which enemy you mean.

You can add as many descriptive conditions to define which instance to pick. Collisions, variables, expressions:

[code:24xj4a1s]
+enemy is overlapping trap
+enemy.Value('armor') is equal to 0
+enemy is visible
->enemy: destroy
[/code:24xj4a1s]

Out of all the enemies in the game, only the ones that meet all those criteria will be destroyed.[/quote:24xj4a1s]

My event for a Spike (my "enemy") is set up so that when the player walks under the spike it will rise up and kill him, however when i use it, it makes both the spikes rise up when the second spike is walked above (they are next to eachother). I want them to operate separately from eachother.

Here is the events for it:

[code:24xj4a1s]
+Player X is great or equal to Spike.Left
-> spike: Set 'isGoingUp' to 1
+Value 'steps' Equal to 4
-> spike: Set 'isGoingUp' to 0
+Value 'isGoingUp' Equal to 1
-> spike: Set Y to .Y - (300 * TimeDelta)
-> spike: Add 1 to 'steps'
[/code:24xj4a1s]

Any help would be appreciated.
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 10:51 am

[quote="Speljohan":1qcyywja]Here is the events for it:

[code:1qcyywja]
+Player X is great or equal to Spike.Left
-> spike: Set 'isGoingUp' to 1
+Value 'steps' Equal to 4
-> spike: Set 'isGoingUp' to 0
+Value 'isGoingUp' Equal to 1
-> spike: Set Y to .Y - (300 * TimeDelta)
-> spike: Add 1 to 'steps'
[/code:1qcyywja]

Any help would be appreciated.[/quote:1qcyywja]

Again, you have to define which spike you're talking about in the conditions. This...

[code:1qcyywja]
+Player X is great or equal to Spike.Left
[/code:1qcyywja]

...does not tell Construct which spike you're talking about. Since Construct doesn't know which one to do, it's setting all your spikes' 'isGoingUp' to 1. So by the time you get to the event that moves your spikes, they all move because they all have 1 in that variable.

You need a more descriptive way to define which spike you want to move.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 09, 2009 10:53 am

[quote="deadeye":1hm3z8bs][quote="Speljohan":1hm3z8bs]Here is the events for it:

[code:1hm3z8bs]
+Player X is great or equal to Spike.Left
-> spike: Set 'isGoingUp' to 1
+Value 'steps' Equal to 4
-> spike: Set 'isGoingUp' to 0
+Value 'isGoingUp' Equal to 1
-> spike: Set Y to .Y - (300 * TimeDelta)
-> spike: Add 1 to 'steps'
[/code:1hm3z8bs]

Any help would be appreciated.[/quote:1hm3z8bs]

Again, you have to define which spike you're talking about in the conditions. This...

[code:1hm3z8bs]
+Player X is great or equal to Spike.Left
[/code:1hm3z8bs]

...does not tell Construct which spike you're talking about. Since Construct doesn't know which one to do, it's setting all your spikes' 'isGoingUp' to 1. So by the time you get to the event that moves your spikes, they all move because they all have 1 in that variable.

You need a more descriptive way to define which spike you want to move.[/quote:1hm3z8bs]
Yes, i am aware of that, however i don't see a way of doing it without creating more events which results in a messy event editor :/
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 11:14 am

It's not messy if it's necessary.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 09, 2009 11:25 am

[quote="deadeye":15dx60zt]It's not messy if it's necessary.[/quote:15dx60zt]
One thing i'd like to see is assigning scripts to certain sprites so you could reuse the same code for several objects. That would be sweet for these kind of things.
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 2:36 pm

try programming it using families then does essentially the same thing.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Jan 09, 2009 2:47 pm

I kind of get the impression you want Construct to magically know which sprite you actually mean, no offense intended. But if you're using improper conditions your events won't do what you want them to.

Maybe you could post the cap, so people could give you examples on how to fix it.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Jan 09, 2009 2:52 pm

[quote="PixelRebirth":1yqw8usw]I kind of get the impression you want Construct to magically know which sprite you actually mean, no offense intended. But if you're using improper conditions your events won't do what you want them to.

Maybe you could post the cap, so people could give you examples on how to fix it.[/quote:1yqw8usw]
I am aware of this, my question actually was if there was a way to get an instance of a sprite in the event editor, but apparently there isn't :/ Since the engine itself (obviously) knows how many instances of a sprite and their properties on the layout, the editor should have a way of picking these.
B
1
G
3
Posts: 8
Reputation: 841

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 11 guests