How do I freeze a single object ?

0 favourites
  • 12 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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 ?

  • The real question is, how have you been freezing the entire layout? 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.

  • 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.

  • 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:

    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

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 ?

  • why not do Group block and put in the event that you want disable and then make the group inactive ?

  • 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).

  • 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.

  • That is possible. But it will take some coding.

    Say you have a boolean that is true when things are in pauze.

    So,

    when the boolean is true (+ once while true condition) you store the Timer expression .. Duration(tag) in a instance variable. The time you wanted to go minus the Duration(tag) = the remaining time.

    When the boolean is false (+ once while true condition), restart the timer with the remaining time.

    Now, its the gravity thing that keeps you from just timescaling. When you can timescale, the timer just pauzes and picks up where it was.

  • Or I just maybe got another idea. Maybe I can spawn an invisible decoy with the platform behaviour that the player will automatically get on top of every tick or soever, allowing the object to fake genuine gravity. Once the player loses the frozen status, the decoy would be destroyed.

    Oh, by the way... There is just another thing that I would need to be helped on. Y'see, I have a container that contains two objects : A tiled background that looks like a thin wooden log, and a sprite that is a spiky "head" of the log. I would like the tiled background part to automatically extend and lower size to fit perfectly with the head, that will move. Does anyone have an idea how to make this simple ? Imagine a Sine behaviour for the head, that would go up and down, but do not recommend me to use Sine size for the tiled background because it's here just an example.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)