Triggering events for objects at certain point

Get help using Construct 2

Post » Sun Apr 28, 2013 4:26 am

I have some dogs that I spawn on either the left hand side, or the right hand side. When they are created I give an instance variable a value of int(random(48, 592)) and they run across the screen. I am trying to trigger a series of events when the dogs reach an x position of int(dog.x) = dog.pooSpot Currently, I am doing it like so:
however, it's not getting all the dogs to go poo. How can I make sure they all do it?
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Sun Apr 28, 2013 2:21 pm

the dog is probably passing over the pooSpot so the condition is never met

if the pooSpot.x is 200 for example..
the dog.x might go from 198 to 202 in a single tick.. it depends on its speed

a way around this would be to change
pspot = int(dog.x)

to

system| is inbetween values:
pspot.x-16 > dog.x > pspot.x+16

this means if the dog is within 16 px of the spot, the condition is met.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Sun Apr 28, 2013 4:05 pm

That makes perfect sense, thanks a bunch.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656


Return to How do I....?

Who is online

Users browsing this forum: Vallar and 17 guests