Bullet problem

Get help using Construct 2

Post » Tue Jul 02, 2013 2:58 am

I want an object bullet behavior X to stop at a distance.
But this does not stop.

On start of layout->Sprite.Bullet.Angle = 0
                                 Sprite.Bullet.Speed = 100

Sprite.X = Self.X+100->Sprite.Bullet.Speed = 0

But it does not work...

CAPX
B
46
S
11
G
5
Posts: 124
Reputation: 6,771

Post » Tue Jul 02, 2013 7:06 am

There is a build in action to bullet behaviour called "compare distance travelled" or something like that, which will trigger whenever the bullet have travelled a certain distance. Have you tried that?

Also In your example you use self.x, doesn't that keep changing the original X position of the bullet, didn't you mean to test if the bullet have travelled 100 pixel from its starting position?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Tue Jul 02, 2013 10:38 am

I had problems with it too, I solved this with
every tick->bullet.x>1500->set bullet X to 1500
B
14
S
5
G
4
Posts: 107
Reputation: 4,788

Post » Tue Jul 02, 2013 11:47 am

bullet distance travelled works, if over a certain amount set speed bullet to 0
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017

Post » Tue Jul 02, 2013 8:29 pm

@nimos100:
Yes, I tried the expression "bullet distance travelled" did not work.
Yes, exactly want that when the bullet has traveled eg 100 pixels, this stops.

@trollface:Your code does not help. I want every x pixels the scroll projectile, this stops.

@vtrix:This action does not work.

B
46
S
11
G
5
Posts: 124
Reputation: 6,771

Post » Tue Jul 02, 2013 8:35 pm

Your condition is wrong, since its really difficult to make sure that your sprite (Bullet) hits and exact integer factor. The chance that it will hit exactly 100 is very slim. You can just change the "Bullet distance travelled" to "Bullet distance travelled >= 100" and then it works.nimos1002013-07-02 20:45:26
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Tue Jul 02, 2013 9:19 pm

@nimos100:Yes and no, because I'm looking for that since the new position can move every 250 pixels.
B
46
S
11
G
5
Posts: 124
Reputation: 6,771

Post » Tue Jul 02, 2013 9:31 pm

The idea is to make a screen selection menu lively.
The selection menu would be like this game:
http://www.youtube.com/watch?v=fqMcDQCNO4s
B
46
S
11
G
5
Posts: 124
Reputation: 6,771

Post » Tue Jul 02, 2013 9:43 pm

Hmm then I think you might be better off just using an "every tick" with a Set sprite.x = sprite.x + 2 or whatever will hit the exact conditions you need.

Or you can add a check that will set the sprite to the correct position you need after it reach it.

So if "Bullet distance travelled >= 100" -> Set sprite.x = 100. And if you need to make it more dynamic, just store the sprite.x start position, and calculate what the new condition should be, based on that. So if its every 100 pixel.

You can compare the starting condition to the sprite current position and divide it by 100 and multiply that with 100.

So instead of sprite.x = 100, you make it:

sprite.x = Round((Starting_position + sprite.X)/100) * 100

However depending on which way the sprite is travelling you need to change the + to - I think, to make it work.

So if its travelling left it needs to be:
starting_position - sprite.x

And if its travelling right it needs to be:
starting_position + sprite.x

At least I think it will work. But math aint exactly my strongest point to be honest, so it might be wrong as I haven't tested it. :D But you can probably see if it works if you do it that way.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Tue Jul 02, 2013 11:15 pm

ok! I will test and if it works share the capx.
B
46
S
11
G
5
Posts: 124
Reputation: 6,771

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests