How do I add random obstacle with different damage to player

0 favourites
  • 5 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hello everyone! just new to construct 2. I just wanna ask how can i add a random obstacle with different damage to the player.

    obstacles:

    Obstacle 1: damage is 50

    Obstacle 2: damage is 100

    Obstacle 3: add health by 150

    I am using the template: Autorunner from construct 2. From what i understood on that template it is creating random blocks. So what i want is on a certain block there will be certain obstacle on which when the player collide

    it will damage or add health to the player.

    Thank you.

  • Hey Bobcool15,

    Take a look in the manual for the section on instance variables.

    Basically, you can give objects extra values called instance variables. Once your player collides with an obstacle you can check if any of those fields are filled and if so, apply the effect.

    Here is a small example.

    https://db.tt/qfrRkhUv

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thank you GenkiGenga for your prompt response and for your example codes for the collision. It is a great help.

    But what about on creating random powerups by block. I am using the construct 2 Template: Auto runner

    Many thanks. Cheers!

  • Example capx

    The added elements are not commented in the event sheet.

    I've had to add a "HP" instance variable to the Player object. It is not managed any further, that's up to you.

    In this example Obstacle and Powerup objects are the only object you add. The damage quantity depends on the Sprite frame being displayed (3rd frame causes 150 damages/heals 150 HP whereas frame 1 only damages/cures 50).

    This is a simple implementation example, but depending on your project and its specifications (would obstacles really require to be different object types ?) the implementation could be very different.

  • Wow Kyatric this is just what i need. You hit it bro.

    This is a great start for me to learn construct 2.

    Thank you so much!

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