How do I make a object go up and down from behind

0 favourites
  • 6 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • Hi,

    I am trying to figure out how to make a spike come out from behind a wall tile repeatedly, it comes down then goes back up behind the wall tile and then does it again and again like a loop. I have tried all variants of movement, sine, 8 direction, bullet etc... either I am doing something wrong with those or not doing it correctly at all as I could not get it working. If someone could show me in contstruct 2 via an example file or give me specific instructions on how to achieve this, would be great?

  • well define the object as a sprite.. then add the sine behaviour, and change the movement to being vertical.

    then using layers, put it behind another object so that it is not visible when it is "down" and then it pokes up.

  • ok thanks will give it a try.

  • ok so I defined my object as a sprite which I was not doing before. Added sine movement to vertical. Do not get what you mean about the layers exactly. Anyway it does not work I need it to only go up and down only by a few pixels, using sine I can't figure out how you define such a thing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, here's a little example with spikes that goes underground endlessly. I set up three types of spikes, just changing the "wave" property of the Sine behavior. Note that the "sawtooth" wave equation is probably what you want. Just check the collision with the sprite and players/entities and do as you like. You can add randomized values to the Sine behavior if you want it to be less predictable. The "width/height" parameters of the "movement" property could be good too as it scales the objects. The magnitude is how large is the movement, in pixels or percents.

    You can see that the spikes are on the "behind" layer, with "tilemap" layer in front.

    This is a simple way to do that. You can also have custom movement by writing your own and changing state and position of the spike object every tick or less. For example you can add a "active" bolean variable to the sprite and set it true only while it's rising from the ground, setting false while retracting. When you're checking for collisions you can also check for if the spike is active or not. If it is, hurt the player, if not, the player can walk upon it.

    Hope this helps if you haven't already find a solution.

    https://www.dropbox.com/s/9xusp6gx0y00e0u/spikes.capx?dl=0

    Cheers

    Nabu

  • The only way I have figured out how to achieve this is by changing my tiles, where I only use one I now use two which solves the problem I am having. Thanks for your help!

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