# How do I Make Falling Dangers

Get help using Construct 2

### » Tue Nov 15, 2016 10:11 pm

Hello, so I am trying to add a danger in my game of a falling spike that falls when the main sprite enters a certain area and will destroy the sprite if it falls on them. Any ideas?
Thanks
B
3
Posts: 11
Reputation: 201

### » Thu Nov 17, 2016 7:28 am

Use sprite coordinates. (I'm assuming this is a side-scroller game) Make an event that says "If player X is equal to Spike X, Spike animation "Fall" plays.
If Spike animation "Fall" is playing and Player collides with Spike, Player is destroyed.

That's the basic logic behind this particular event. Explore the sprite events and you will find the conditions in each one that will allow you to do this. There's never just one way of doing things, you can cause this same effect in many different ways. When you get the basics down you will find different methods that best suits your development logic.
B
26
S
9
G
4
Posts: 104
Reputation: 4,056

### » Thu Nov 17, 2016 9:37 am

"If player X is equal to Spike X ...

That is virtual impossible (with the exception of exact grid movements).
Positions have mostly a (in context to evaluating kinda randomly) fractional part.

So, 'is equal' has no chance.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu Nov 17, 2016 11:51 am

I doubt C2 would have the option for "is equal to" if it was not possible to use. It works for me every time. If you have a better alternative then perhaps you should post it.
Anyway, use the advise or not, it's just my 2 cents.
B
26
S
9
G
4
Posts: 104
Reputation: 4,056

### » Thu Nov 17, 2016 10:03 pm

Thank you both for your advice I will see if it works
B
3
Posts: 11
Reputation: 201

### » Fri Nov 18, 2016 8:29 am

Try the Line-of-sight behavior. With a small cone. Dont forget to place the spikes with theire angle down.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Fri Nov 18, 2016 1:23 pm

When dealing with a moving object it is indeed more appropriate to look for a range than a single absolute value, as, unless a precise movement (like a determined grid movement), most of the chances are that your object won't actually reach the exact position you are testing.
By checking for a range, ( Object.X >= end position - 10 & Object.X <= end position + 10) you will always be sure to be able to trigger your end of movement within an appropriate range and can then move your object to the intended ending position.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
311
S
128
G
101
Posts: 7,414
Reputation: 75,224