How do I keep my bullets from changing direction?

Get help using Construct 2

Post » Thu Sep 29, 2016 4:35 pm

Hi,

I have a Boss who spawns a bullet object (Eball) every three seconds, whenever he gets Line of Sight to the Player. That part works.

But the Boss is set to travel back and forth in the Boss chamber, changing direction whenever he hits the wall.

And the bullets do the same thing. If they're still onscreen, they will change with him. Otherwise they get Destroyed when they go offscreen.

How to make the bullet's independent so that they don't follow the Boss's direction? Code below (for Boss movement and bullet spawning):

Image


Is it a setting in the Bullet Behaviour for the bullet object (Eball)?

Any suggestions etc. greatly appreciated,

thanks,
M

Image
B
7
S
1
Posts: 23
Reputation: 421

Post » Thu Sep 29, 2016 4:49 pm

Well maybe that's not what's happening now.

NOW, since I'm destroying the bullet every time the Boss changes direction, the bullet does NOT change direction as previously stated. But the bullet disappears when the Boss changes direction, which looks odd.

I'm having the bullet destroyed because when I don't, the bullets DO change direction with the Boss.

At this point, trying to figure out how to keep that bullet on screen (not being destroyed mid-flight) when the Boss abruptly changes direction.

I added the Fade behaviour to the bullets so that they taper off in opacity and we don't notice any abrupt exiting.
B
7
S
1
Posts: 23
Reputation: 421

Post » Thu Sep 29, 2016 11:42 pm

I don't see the issue with the events you posted, but you said that those aren't the events that were causing the problem, so that doesn't help much.

Anyway, I've had similar issue, the problem was if you spawn a bullet then change the direction you are fine, but if the bullet gets destroyed before the the angle is set then it picks all the bullets. LOS may be going in and out quickly? not sure, so maybe this doesn't apply.

Anyway, first thing I would try is 'On Bullet Created' -> set angle to: boss.direction = "right" ? 0 : 180

(if you don't know the ?: I recommend learning, very useful)
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Fri Sep 30, 2016 12:09 pm

Thanks badmoodtaylor, that bit of code worked, however I confess I don't understand the ?.

I ended up setting the angle of the bullet to 180 or 0 based on whether the Boss is mirrored or not. That's because I also changed the Boss so that he always faces the Player, whether he's moving away or towards him. It's looking good, in a simple as shit 8-bit boss kind of way, thanks for your help!
B
7
S
1
Posts: 23
Reputation: 421

Post » Fri Sep 30, 2016 1:59 pm

You are welcome. the ?: looks confusing at first glance but it is very simple. Type a condition then put a question mark. Then type the result if true, put a colon : and then what the result is if false.

So to test it out if you have a global variable called SCORE and a textbox, choose the action set text and type:
Score < 200 ? "Good" : "Great"

If score is less than 200 the textbox will say good. 200 or more and the texboxt will say great.

Description from elsewhere:
?: is a conditional operator, which allows you to test conditions in expressions. This is especially useful when used with the comparison operators and logical operators. It takes the form condition ? result_if_true : result_if_false
e.g. health < 0 | score < 0 ? "Game over!" : "Keep going!".
The condition counts as true if it is non-zero, and false if it is zero.
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests