Bullet system

Get help using Construct 2

Post » Mon Jan 30, 2012 10:11 pm

Quick one:
How can I make a character shoot but not so fast? My char shoots, but I haven't found a control (or a way) to limit the number of bullets produced, so he just fires really fast.

So, a facility of "Create X object after X time has passed" would be great.

Any way to simplify? I'd prefer not to use plugins, as exploring all of Constructs abilities is my main objective.

Thanks.
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Mon Jan 30, 2012 10:50 pm

you have every x ms system expression, but also I'd recommend using instance variables for player (that's how I roll :)

1) shoottimeout = interval in milliseconds
2) readytoshootin = 0

shoot button is pressed && readytoshootin <= 0
-> create bullet
-> set readytoshootin to shoottimeout

readytoshootin > 0
-> set readytoshootin = readytoshootin - dt
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Jan 30, 2012 11:44 pm

Thanks for the help. Got a different solution, but cheers, mate.

Here's what I came out:
Set a "shoot" global variable.
At key press, if "shoot"=0, create bullet, set "shoot" to 5.
On each tick, and if shoot >=1, take 1 from "shoot".eyeliner2012-01-30 23:48:05
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Tue Jan 31, 2012 12:03 am

well this is preety much the same, but you didn't take into account the delta time (dt expression) which can really mess up your creation :) cheers!
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun May 20, 2012 5:30 pm

Hi! I reopen this thread with another bullet behavior issue; I'm trying to make the bullet destroys itself whem colliding with any solid but I can't find any event similar to "on collision with a solid" or something like that. I supose it should be an easy task but I coudn't find it.

thanks!

B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Mon May 21, 2012 12:10 am

Hi Antylope,

I think what you're after is on the "event sheet" -> event -> collisions -"on collision with another object".
hope it helps.

br,
j.pinela
B
2
Posts: 1
Reputation: 252

Post » Tue May 22, 2012 4:50 am

As far as I tried, the event "on collision with another object" makes you specify an object; what a I want is more global: when it collides with any object whatever it could be.

I could add an invisible wall in front of any solid and use it as target for that event but I supose there's an easier way to do it.

Any ideas?
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Tue May 22, 2012 5:10 am

While you're waiting for a better solution from a more experienced user, here's two solutions I can think of:

1. Define a new family called 'SolidObject', and add all your solids to this family. Test for a collision with 'SolidObject'. The down side to this is that every time you create a new solid you need to add it to the 'SolidObject' family.

2. This is more hack-ish, but add a Platform Movement behavior to your bullet and set all the attributes to 0, and the 'Default Controls' to no. Now Platform Movement doesn't really do much except give you a new condition to test for. In your events test for 'Is by wall' for left and for right. Use an OR to test for both sides, and destroy it in the action. The benefit of this is that you don't have to worry about classifying all your solids.Dalal2012-05-22 05:14:17
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Wed May 23, 2012 4:39 am

jajaja! It's not bad actually. I'm out of the 1st option since I cant use families (still in standard edition). I'll try the 2nd option.

thanks
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Wed May 23, 2012 4:50 am

Instead of using families, make a layer called Collision, and make a tiny red box (like, 5x5 pixels), and spread it around where there is collision. Make THIS object solid. Check for collision against this object only. Make sure to make this layer invisible, though (or probably toggle-able, if you want to have a 'debug' area).

This is probably something you should end up doing normally, because it removes ambiguity in collision detection.
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Khamsou, Yura G and 13 guests