How do I add random obstacle with different damage to player

Get help using Construct 2

Post » Tue Jun 02, 2015 7:03 am

Hello everyone! just new to construct 2. I just wanna ask how can i add a random obstacle with different damage to the player.


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.
Posts: 8
Reputation: 216

Post » Tue Jun 02, 2015 10:06 pm

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.
Last edited by GenkiGenga on Fri Jun 05, 2015 12:50 am, edited 1 time in total.
Posts: 1,103
Reputation: 14,477

Post » Wed Jun 03, 2015 1:00 am

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!
Posts: 8
Reputation: 216

Post » Wed Jun 03, 2015 11:33 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Posts: 7,432
Reputation: 75,388

Post » Thu Jun 04, 2015 8:47 am

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!
Posts: 8
Reputation: 216

Return to How do I....?

Who is online

Users browsing this forum: sofiabatte and 3 guests