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

This forum is currently in read-only mode.
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • 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?

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

    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:

    +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 [i]every[/i] 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 [i]all[/i] those criteria will be destroyed.
  • > 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?

    >

    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:

    > +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 [i]every[/i] 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 [i]all[/i] those criteria will be destroyed.
    

    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:

    +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.
  • Here is the events for it:

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

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

    +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.
  • > Here is the events for it:

    >

    >

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

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

  • It's not messy if it's necessary.

  • It's not messy if it's necessary.

    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.

  • try programming it using families then does essentially the same thing.

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

  • Try Construct 3

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

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

    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.

  • Why don't you just store the distance between player and enemy in a private variable (of the enemy). Then you check the distance and if it's below a certain number of pixels and Player.Y is greater than Enemy.Y => enemy attacks. Just an example. Could be more specific about it if you posted the cap.

    I have a distance value to all my enemy sprites, since it's useful in many situations.

  • Why don't you just store the distance between player and enemy in a private variable (of the enemy). Then you check the distance and if it's below a certain number of pixels and Player.Y is greater than Enemy.Y => enemy attacks. Just an example. Could be more specific about it if you posted the cap.

    I have a distance value to all my enemy sprites, since it's useful in many situations.

    Yes, it's a possible way, problem is i'm used to programming where i can just create a function/class and re-use it at a later time. If that was possible here it would be so much easier ^^

  • Why would you not be able to reuse it? Just recalculate the distance variable to be stored as needed.

    And there is a function object that creates functions you can call on any time, fyi.

  • Also, if you'd like to create "Objects" in the sense that Object Oriented Programming uses the word (where you can assign functions and even other objects to an object) then in Construct try putting everything into a container and think of that as your "Class".

  • At the moment you only seem to be checking if Player.x is greater or equal to Spike.Left. You'll need to add another condition checking if Player.x is lower than Spike.Right, that way it'll only pick the spike that you're within the bounds of.

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