How do I freeze a single object ?

Get help using Construct 2

Post » Sun Aug 21, 2016 10:41 pm

Hello there.

In order to make ice-based or time-based enemies that freeze the player when they get hit, I would like to completely freeze not the whole game but ONLY a specific object, here the player.

The issue is that once the conditions for a event are met and the event triggered, the event cannot stop and restart where it was left if a condition is no longer true. Otherwise said, I would like all actions of a specific object to completely stop and then, when ice gets off, get back right where the events were left. And I really have no idea how to do this. I've been thinking at loops but it doesn't seem to be what I'm looking for. I even doubt this is possible. I've been searching a bit but no one has asked this before, so I'm doing it myself : How could I stop a single object and not the entire layout ?
B
8
Posts: 11
Reputation: 328

Post » Sun Aug 21, 2016 11:43 pm

The real question is, how have you been freezing the entire layout? :D I think what you're looking for is a condition using probably a boolean isFrozen. Set up the player conditions, and then add the condition in isFrozen(inverted), so conditions run only when player is not frozen. When player is frozen, set isFrozen to true, when player is not frozen (I assume after an amount of time or something) then set isFrozen to false.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Aug 22, 2016 10:38 am

Howdy. I appreciate your reply, but sadly, this won't help me. :(

It if was that simple, I would probably have not asked about this. I indeed thought off of this solution, but as I told earlier, given how events work, it wouldn't work.

Say, imagine it as a Time Stop rather than an ice attack. I would need the player to completely stop from moving, stop their animation, and lose any control above their character. It is easy to disable controls, however the problem I have is that I need the event to totally stop.

Your solution would work if the event haven't been triggered yet, but imagine a timed event. For example, something like that :

When F is pressed
[X] Triggered is set

- > Set Triggered to true
Wait 0.5 second
Spawn "PlayerBullet" from Player
Set Triggered to false

Just forget what this event does, that's not the matter. The thing is that, as you can see, I have triggered the "Triggered" boolean as soon as the event started, in order for the event not to trigger itself multiple times. This is kind of hard to explain if you do not understand how events work.

To make it simple, events are triggered multiples times in a second (every tick, I suppose) as long as the conditions are met. If the conditions are no longer met, for this example if the player gets frozen before the bullet was released, the event will still continue itself until its end. What I am looking for is how to stop an already triggered event. In other words, how to make an event that, during execution, will instantly stop if one of the conditions are no longer met, or if another variable changes or whatever, you got what I mean. And I don't know how to do this.

To get back to my example, if I followed your idea, the bullet would've been released even if the player was frozen between keyboard input and actual release of the bullet.
B
8
Posts: 11
Reputation: 328

Post » Mon Aug 22, 2016 10:48 am

Have you tried to set the objects time scale to 0? Then that object is totally frozen until you reset it.

And to stop an event which uses wait like you mentioned you can set an event with a sub event like this:

Image

So if the enemy gets frozen during the wait part of the event it will not trigger the spawning when reaching the sub event.

Very easy to do but hard to explain :P
Last edited by Anonnymitet on Mon Aug 22, 2016 10:54 am, edited 1 time in total.
B
54
S
23
G
12
Posts: 747
Reputation: 11,910

Post » Mon Aug 22, 2016 10:50 am

Dont use 'wait', use timers. In fact, never use 'wait'.
Then use the system action:

Set object time scale
Restore object time scale
Change the rate time passes for a specific object. This affects the object's behaviors and its own dt expression. Restoring the object's time scale returns it to the same time scale the rest of the game is using.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 22, 2016 10:57 am

99Instances2Go wrote:Dont use 'wait', use timers. In fact, never use 'wait'.
Then use the system action:

Set object time scale
Restore object time scale
Change the rate time passes for a specific object. This affects the object's behaviors and its own dt expression. Restoring the object's time scale returns it to the same time scale the rest of the game is using.


I agree. Using timers and signals are way better than wait actions no doubt.
B
54
S
23
G
12
Posts: 747
Reputation: 11,910

Post » Mon Aug 22, 2016 1:30 pm

Okay, thank you, then it would work for a Time Stopper, but do you know if I can stop all events and timers currently in use like I can with Time Scale but still let the object be affected by gravity ? I think there is a way. You know what I want to do : A freeze effect, that would stop all events of the player currently triggered but do not prevent them from falling. Is it possible ?
B
8
Posts: 11
Reputation: 328

Post » Mon Aug 22, 2016 1:46 pm

why not do Group block and put in the event that you want disable and then make the group inactive ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Mon Aug 22, 2016 4:49 pm

Suppose it is a platformer. Then it depends on if you are using default or custom keys.

Using custom ? Go with Gearworkdragon. On Timer events must also be in that group.

Using default? Go with a instance boolean. On Timer events get company of a condition that evaluates the boolean. And there is an action to dissable keyboard for the platform. (when the boolean is true).
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 22, 2016 5:44 pm

This indeed is a platformer. I haven't tried this solution yet, but I will try as soon as I'll need a frozen status. Great thanks. The only thing that's too bad is that the timed events won't get back where they were stopped when the group will recover activity, but that doesn't really matter, does it ? For now, I don't really need it, and anyway I don't think there's a real way to do it.
B
8
Posts: 11
Reputation: 328

Next

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 19 guests