How do I stop a bullet

Get help using Construct 2

Post » Thu Oct 01, 2015 12:55 pm

This is my code

keyboard on right arrow pressed: ball set bullet enabled
ball X = 280: ball set bulllet disabled

ball does not stop.
why
B
8
S
3
G
2
Posts: 53
Reputation: 1,764

Post » Thu Oct 01, 2015 1:18 pm

Because your ball never hit exactly x=280.
If you have a speed of 240 in your bullet-behavior, the ball will travel 4 pixel each tick, if you set the ball in the beginning to x=1 every tick it will travel 4 pixel, so after the first tick it is x=5 then x= 9 and at least x=277 and x=281
so it will never trigger x=280.
Even if you set it to x=0 a little slowdown could alter delta time and you will miss x=280 again.
Better is to use x>280.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Thu Oct 01, 2015 3:14 pm

try using the bullet parameter sprite.bullet.distancetraveled >=(greater or equal) to 280 = disable bullet

this way when ur bullet will travel 280 pixels in any direction you point it at will disable itself.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005


Return to How do I....?

Who is online

Users browsing this forum: jezjones24 and 23 guests